Skip to content

Commit 73cbb22

Browse files
authored
Make String.opBinaryRight @safe when possible and qualify test as @safe (#377)
* Make String.opBinaryRight @safe when possible and qualify test as @safe * Remove two more @System qualifiers
1 parent e49ec32 commit 73cbb22

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

source/mir/string_map.d

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Checks if the type is instance of $(LREF StringMap).
1313
+/
1414
enum isStringMap(T) = is(Unqual!T == StringMap!V, V);
1515

16-
version(mir_test)
16+
version(mir_test)
1717
///
1818
unittest
1919
{
@@ -297,10 +297,10 @@ struct StringMap(T, U = uint)
297297
}
298298

299299
/++
300-
Reserves capacity for an associative array.
300+
Reserves capacity for an associative array.
301301
The capacity is the size that the underlaying slices can grow to before the underlying arrays may be reallocated or extended.
302302
+/
303-
size_t reserve()(size_t newcapacity) @trusted pure nothrow
303+
size_t reserve()(size_t newcapacity) @trusted pure nothrow
304304
{
305305
import mir.utility: min;
306306

@@ -355,7 +355,7 @@ struct StringMap(T, U = uint)
355355
356356
Returns: The input is returned.
357357
+/
358-
ref inout(typeof(this)) assumeSafeAppend()() @system nothrow inout return
358+
ref inout(typeof(this)) assumeSafeAppend()() nothrow inout return
359359
{
360360
if (implementation)
361361
{
@@ -442,7 +442,7 @@ struct StringMap(T, U = uint)
442442

443443
/++
444444
Finds position of the key in the associative array .
445-
445+
446446
Return: An index starting from `0` that corresponds to the key or `-1` if the associative array doesn't contain the key.
447447
448448
Complexity: `O(log(s))`, where `s` is the number of the keys with the same length as the input key.
@@ -481,7 +481,7 @@ struct StringMap(T, U = uint)
481481
/++
482482
Complexity: `O(log(s))`, where `s` is the number of the keys with the same length as the input key.
483483
+/
484-
inout(T)* opBinaryRight(string op : "in")(scope const(char)[] key) @system pure nothrow @nogc inout
484+
inout(T)* opBinaryRight(string op : "in")(scope const(char)[] key) pure nothrow @nogc inout
485485
{
486486
if (!implementation)
487487
return null;
@@ -491,12 +491,12 @@ struct StringMap(T, U = uint)
491491
assert (index < length);
492492
index = implementation.indices[index];
493493
assert (index < length);
494-
return implementation._values + index;
494+
return &implementation.values[index];
495495
}
496496

497497
version(mir_test) static if (is(T == int))
498498
///
499-
@system nothrow pure unittest
499+
@safe nothrow pure unittest
500500
{
501501
StringMap!double map;
502502
assert(("c" in map) is null);
@@ -712,7 +712,7 @@ struct StringMap(T, U = uint)
712712
}
713713
}
714714

715-
version(mir_test)
715+
version(mir_test)
716716
///
717717
unittest
718718
{
@@ -888,17 +888,17 @@ private struct StructImpl(T, U = uint)
888888
{
889889
return _keys[0 .. _length];
890890
}
891-
891+
892892
inout(T)[] values()() @trusted inout @property
893893
{
894894
return _values[0 .. _length];
895895
}
896-
896+
897897
inout(U)[] indices()() @trusted inout @property
898898
{
899899
return _indices[0 .. _length];
900900
}
901-
901+
902902
inout(U)[] lengthTable()() @trusted inout @property
903903
{
904904
return _lengthTable;
@@ -923,7 +923,7 @@ private struct StructImpl(T, U = uint)
923923
auto high = _lengthTable[key.length + 1] + 0u;
924924
while (low < high)
925925
{
926-
auto mid = (low + high) / 2;
926+
const mid = (low + high) / 2;
927927

928928
import core.stdc.string: memcmp;
929929
int r = void;
@@ -950,7 +950,7 @@ private struct StructImpl(T, U = uint)
950950
}
951951

952952
version(mir_test)
953-
unittest
953+
@safe unittest
954954
{
955955
import mir.algebraic_alias.json: JsonAlgebraic;
956956
import mir.string_map: StringMap;

0 commit comments

Comments
 (0)