Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 99c812f

Browse files
committed
Use onRangeError in StringMap.opIndex
1 parent b21ff32 commit 99c812f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎source/mir/string_map.d

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ struct StringMap(T, U = uint)
532532
/++
533533
Complexity: `O(log(s))`, where `s` is the number of the keys with the same length as the input key.
534534
+/
535-
ref inout(T) opIndex()(scope const(char)[] key) @trusted pure inout //@nogc
535+
ref inout(T) opIndex()(scope const(char)[] key) @trusted pure inout nothrow@nogc
536536
{
537537
size_t index;
538538
if (implementation && implementation.findIndex(key, index))
@@ -542,8 +542,9 @@ struct StringMap(T, U = uint)
542542
assert (index < length);
543543
return implementation._values[index];
544544
}
545-
import mir.exception: MirException;
546-
throw new MirException("No member: ", key);
545+
import core.exception : onRangeError;
546+
onRangeError();
547+
return implementation._values[0]; // TODO: remove when onRangeError is noreturn
547548
}
548549

549550
version(mir_test) static if (is(T == int))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /