On Thursday, 15 December 2016 at 23:37:50 UTC, Stefan Koch wrote:
On Thursday, 15 December 2016 at 23:05:55 UTC, Dmitry Olshansky
wrote:
Afaik string switches are implemented as a fairly slow hash
table. Optimal solutions like building a trie would be a nice
enhancement.
---
Dmitry Olshansky
Tries take up alot of memory for sparse tables.
I would like to avoid them.
Futhermore, CTFE is targeted towards smaller functions with low
iteration count.
Therefore producing bytecode as fast as possible is priority.
This function from std.uri does now compile and execute
correctly.
private enum
{
URI_Alpha = 1,
URI_Reserved = 2,
URI_Mark = 4,
URI_Digit = 8,
URI_Hash = 0x10, // '#'
}
immutable ubyte[128] uri_flags = // indexed by character
({
ubyte[128] uflags;
// Compile time initialize
uflags['#'] |= URI_Hash;
foreach (c; 'A' .. 'Z' + 1)
{
uflags[c] |= URI_Alpha;
uflags[c + 0x20] |= URI_Alpha; // lowercase
letters
}
foreach (c; '0' .. '9' + 1) uflags[c] |= URI_Digit;
foreach (c; ";/?:@&=+$,") uflags[c] |= URI_Reserved;
foreach (c; "-_.!~*'()") uflags[c] |= URI_Mark;
return uflags;
})();
I have to say I was surprised myself :)
It takes around 30 us to execute, which can be improved for
sure :)
Hey Guys, I just had a mental breakthrough in regards to handling
doubly in-directed read-modify-write operations.
such as changing the length of an array through a pointer.
Refernce values will carry a typed pointer to their origin
thereby allowing them to be treated like normal values most of
the time, and only receive special treatment on assignment.
(Which is where they have to emit a Store32 Instead of a Set)
As this has design implications, I will resolve this before
continuing function-call support.
In fact, I think I will have to delay call support until most of
the ABI issues are worked out.