Table lookups - this is pretty definitive

monarch_dodra monarchdodra at gmail.com
Wed Apr 2 23:19:26 PDT 2014


On Wednesday, 2 April 2014 at 21:18:19 UTC, Dmitry Olshansky 
wrote:
> 03-Apr-2014 00:46, Walter Bright пишет:
>> On 4/2/2014 12:38 PM, Dmitry Olshansky wrote:
>> memchr is already optimized by SIMD, and std.algorithm.find 
>> uses memchr.
>> In general, enormous effort has been poured into optimizing C 
>> standard
>> library functions. If an algorithm can be implemented using 
>> such
>> functions, we ought to.
>
> This is all good and well, but...
> memchr is working on the level of a single byte, leaving 
> nothing for 2, 4, 8 byte-wide needles. Not type-safe. No 
> fallback for CTFE.

I found myself needing "wmemchr" (and optionally "dmemchr") for 
speeding up find for wstrings and dstrings.

I realized "wmemchr" exists, but it is platform defined: ushort 
(w) on windows, and uint (d) on linux.

So it's hard to use, and definitely not the "W" version I'd 
expect in D code.

If I were to request the actual "memchr"/"wmemchr"/"dmemchr" 
functions in some "core.???" module, is this something we'd want, 
and would somebody know how to provide an efficient 
implementation?


More information about the Digitalmars-d mailing list