[Geany-Devel] On document pointer recycling

Matthew Brush mbrush at xxxxx
Fri Oct 25 02:52:25 UTC 2013


On 13-10-24 02:51 PM, Lex Trotman wrote:
> On 25 October 2013 04:04, Dimitar Zhekov <dimitar.zhekov at gmail.com> wrote:
>
>> On Thu, 24 Oct 2013 19:22:34 +1100
>> Lex Trotman <elextr at gmail.com> wrote:
>>
>>> Unfortunately there is an accessor document_index() in the plugin
>> interface
>>> that uses the index into the array.
>>>
>>> Switching to a list means that there needs to be a change everywhere in
>>> Geany and the plugins that the array index is used instead of a pointer.
>>   I
>>> don't see anywhere where the index is used inside Geany but I may have
>>> missed somewhere.  I don't know how often its used by plugins.  But again
>>> its use could be deprecated and a temporary map (eg g_tree) from an int
>> to
>>> the pointer could be used until plugins are modified.
>>
>>  From what I see, document_index() is used in the plugins:
>>
>> - inside foreach_document(i), which makes zero sense
>> - in a similar loop in codenav, where the number of documents is
>>    copied in a local variable, without an obvious reason, and there
>>    is no is_valid check
>> - in geanypy, to implement a Python document_index() function.
>>
>
> Thanks.
>
>
>>
>> That being said, just how is a list better than a GPtrArray?
>>
>
> True, its the fact that the index is held constant because it might be
> stored and re-used that stops the array from being shrunk.  Getting rid of
> the use of indexes is the necessary pre-condition for shrinking the array,
> or using a list or whatever.

We could use GHashTable as a Set to contain the documents internally 
afterwards. It doesn't make much sense to have a particular document 
instantiated more than once anyway and the only order we care about for 
documents here is maybe the order/time they were opened, which is better 
solved with a "open timestamp" or something, IMO.

My two cents

Cheers,
Matthew Brush


More information about the Devel mailing list