Skip to content

Commit 47ec85f

Browse files
committed
more betterC adoption
1 parent 317e137 commit 47ec85f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

source/mir/bitmanip.d

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ private string myToString()(ulong n)
2727
{
2828
UnsignedStringBuf buf;
2929
auto s = unsignedToTempString(n, buf);
30-
return cast(string) s ~ (n > uint.max ? "UL" : "U");
30+
return s ~ (n > uint.max ? "UL" : "U");
3131
}
3232

3333
private alias UnsignedStringBuf = char[20];
3434

35-
private char[] unsignedToTempString()(ulong value, return char[] buf, uint radix = 10) @safe
35+
private string unsignedToTempString()(ulong value, char[] buf, uint radix = 10) @safe
3636
{
3737
size_t i = buf.length;
3838
do
@@ -41,7 +41,7 @@ private char[] unsignedToTempString()(ulong value, return char[] buf, uint radix
4141
value = value / radix;
4242
buf[--i] = cast(char)((x < 10) ? x + '0' : x - 10 + 'a');
4343
} while (value);
44-
return buf[i .. $];
44+
return buf[i .. $].idup;
4545
}
4646

4747
private template createAccessors(
@@ -174,18 +174,18 @@ private ulong getBitsForAlign(ulong a)
174174
private template createReferenceAccessor(string store, T, ulong bits, string name)
175175
{
176176
enum storage = "private void* " ~ store ~ "_ptr;\n";
177-
enum storage_accessor = "@property ref size_t " ~ store ~ "() return @trusted pure nothrow @nogc const { "
177+
enum storage_accessor = "@property ref size_t " ~ store ~ "()() return @trusted pure nothrow @nogc const { "
178178
~ "return *cast(size_t*) &" ~ store ~ "_ptr;}\n"
179-
~ "@property void " ~ store ~ "(size_t v) @trusted pure nothrow @nogc { "
179+
~ "@property void " ~ store ~ "()(size_t v) @trusted pure nothrow @nogc { "
180180
~ "" ~ store ~ "_ptr = cast(void*) v;}\n";
181181

182182
enum mask = (1UL << bits) - 1;
183183
// getter
184-
enum ref_accessor = "@property "~T.stringof~" "~name~"() @trusted pure nothrow @nogc const { auto result = "
184+
enum ref_accessor = "@property "~T.stringof~" "~name~"()() @trusted pure nothrow @nogc const { auto result = "
185185
~ "("~store~" & "~myToString(~mask)~"); "
186186
~ "return cast("~T.stringof~") cast(void*) result;}\n"
187187
// setter
188-
~"@property void "~name~"("~T.stringof~" v) @trusted pure nothrow @nogc { "
188+
~"@property void "~name~"()("~T.stringof~" v) @trusted pure nothrow @nogc { "
189189
~"assert(((cast(typeof("~store~")) cast(void*) v) & "~myToString(mask)
190190
~`) == 0, "Value not properly aligned for '`~name~`'"); `
191191
~store~" = cast(typeof("~store~"))"

0 commit comments

Comments
 (0)