DMD internal: appendToModuleMember performance
Johan Engelen via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 23 02:15:02 PDT 2016
On Friday, 22 April 2016 at 23:33:24 UTC, Walter Bright wrote:
> On 4/22/2016 3:07 PM, David Nadlinger wrote:
>> On Friday, 22 April 2016 at 21:48:09 UTC, Walter Bright wrote:
>>> Why not just use a hash table? D's builtin one?
>>
>> Apparently, some parts rely on the insertion order, although
>> I'm not convinced
>> they should. Module::importAll is one of them, but in a way
>> that's trivial to
>> avoid. I didn't check any other locations.
>>
>> If order is not important, a hash set should be fine.
>
> The linear search is checking for membership. Another way is to
> have the 'this' have a field that says which says which
> members[] it is in, if any. Voila, the membership becomes an
> O(1) search.
Excellent. I didn't dare assume the code actually worked that
simply.
More information about the Digitalmars-d
mailing list