diff options
Diffstat (limited to 'compiler/idents.nim')
-rw-r--r-- | compiler/idents.nim | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/idents.nim b/compiler/idents.nim index 1e8c912d9..34177e76d 100644 --- a/compiler/idents.nim +++ b/compiler/idents.nim @@ -11,8 +11,11 @@ # An identifier is a shared immutable string that can be compared by its # id. This module is essential for the compiler's performance. -import - hashes, wordrecg +import wordrecg +import std/hashes + +when defined(nimPreviewSlimSystem): + import std/assertions type PIdent* = ref TIdent @@ -113,3 +116,8 @@ proc newIdentCache*(): IdentCache = proc whichKeyword*(id: PIdent): TSpecialWord = if id.id < 0: result = wInvalid else: result = TSpecialWord(id.id) + +proc hash*(x: PIdent): Hash {.inline.} = x.h +proc `==`*(a, b: PIdent): bool {.inline.} = + if a.isNil or b.isNil: result = system.`==`(a, b) + else: result = a.id == b.id |