DMD internal: appendToModuleMember performance

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 22 16:33:24 PDT 2016


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.



More information about the Digitalmars-d mailing list