On Fri, Feb 22, 2008 at 04:46:44PM -0500, rgheck wrote:
> Andre Poenitz wrote:
>> Does anybody remember why we use a shared pointer and not an index into
>> the global list of textclasses?
>
> Yes, that was my doing.

So this is a recent change?

> It used to be a list of textclasses, when these were static objects.
> But now the textclasses that are in use are dynamic objects: They get
> changed as modules are loaded and unloaded. The shared pointer is
> there because of the following situation: You cut some text, and then
> close the document. The textclass needs to stay with the cut text, so
> it can't just live with the document.
>
> Now we could have some global list of dynamic text classes, and Abdel
> suggested this possibility after I'd already implemented it the other
> way.  The only downside to this is that it might waste memory.

> You don't have to keep the textclasses around forever; only so long as
> something's using them. So if you had the global list and opened a
> document, and then loaded a module, you'd have two entries in the
> global list, since you can't tell (or, at least, it's very hard to
> tell) whether some bit of cut text has a reference to the old one. And
> if you do this a few times, you can end up with several of these lying
> around.

So basically we use the shared pointer to potentially save a few kBytes 
for users opening/closing lots of different documents in a single session?

> Now they're probably not all that huge, so maybe that doesn't matter
> so much. But that was my thinking at the time.

Hm, ok... I see your point, but I think I consider the 'worst case
scenario' described a really rare case and rather have the index based 
solution. [Apart from that, if need arises there could be some 'garbage
collection' of unused classes without much effort...]

Andre'

Reply via email to