How to pass an InputRange of dchars to a function that wants an Input range of chars?
realhet
real_het at hotmail.com
Thu Feb 20 09:14:13 UTC 2025
On Thursday, 20 February 2025 at 03:54:28 UTC, Jonathan M Davis
wrote:
> On Wednesday, February 19, 2025 7:48:48 PM MST Jonathan M Davis
> via Digitalmars-d-learn wrote:
>> So you should probably either just make your code operate on
>> ranges of dchar
Thank You for the deep explanation!
This thing checks is a range of characters starts with a small
set of keywords and returns the index+1 of the particular keyword.
It does not fetches a whole identifier, it lookus up every
character in a tree. The tree is generated as compile time
template functions: every branch is translated to a switch/case
statement, and there comes the hardcore optimization by LDC.
Yesterday, at one point I already decided to transition my code
from chat to dchar.
My actual use case is also presents a complicated range of
dchar-s.
And I just don't constraint the range type with isInputRange(R,
immutable dchar). It generates a nasty error message and if
popFront and empty is not supported it will show it anyways.
On the performance side of 8bit vs 32bit:
It has now 4x more data to work with with. (Mostly because "cmp
ax, im8" operation was replaced by "cmp eax, im32". So the early
I can convert down to 8 bit is the better.)
The keywords I looking for at the beginning of the 'string' are
only 8bit ascii characters, "#define", "#ifdef", and so on.
Because of the dchar it must ensure that the high 24 bits are
zero as well.
But this thing only runs for 1msec (8bit version .5ms) so it will
stay in the dchar form, which - as now I learned - was the
preferred usage at this moment.
I have better understanding now, Thx!
More information about the Digitalmars-d-learn
mailing list