File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -57,12 +57,11 @@ template StringLit(const(char)[] lit, bool zeroTerminate = true)
5757 return buffer;
5858 }();
5959 pragma (aligned, 2 )
60- private __gshared literal = LiteralData;
60+ private __gshared immutable literal = LiteralData;
6161
62- enum String StringLit = String(literal.ptr + 2 , false );
62+ enum StringLit = immutable ( String) (literal.ptr + 2 , false );
6363}
6464
65-
6665String makeString (const (char )[] s) nothrow
6766{
6867 if (s.length == 0 )
@@ -187,7 +186,17 @@ nothrow @nogc:
187186
188187 // TODO: I made this return ushort, but normally length() returns size_t
189188 ushort length () const pure
190- => ptr ? ((cast (ushort * )ptr)[- 1 ] & 0x7FFF ) : 0 ;
189+ {
190+ if (__ctfe)
191+ {
192+ version (LittleEndian )
193+ return ptr ? cast (ushort )(ptr[- 2 ] | (ptr[- 1 ] << 8 )) & 0x7FFF : 0 ;
194+ else
195+ return ptr ? cast (ushort )((ptr[- 1 ] | (ptr[- 2 ] << 8 )) & 0x7FFF ) : 0 ;
196+ }
197+ else
198+ return ptr ? ((cast (ushort * )ptr)[- 1 ] & 0x7FFF ) : 0 ;
199+ }
191200
192201 bool opCast (T : bool )() const pure
193202 => ptr != null && ((cast (ushort * )ptr)[- 1 ] & 0x7FFF ) != 0 ;
You can’t perform that action at this time.
0 commit comments