Skip to content

Commit

Permalink
use memcmp
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Apr 26, 2022
1 parent 195f347 commit a53a81f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/system/arc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ template tearDownForeignThreadGc* =
discard

func endsWith*(s, suffix: cstring): bool {.inline.} =
proc strncmp(str1, str2: cstring, n: csize_t): cint {.importc, header: "<string.h>".}
proc memcmp(str1, str2: cstring, n: csize_t): cint {.importc, header: "<string.h>".}
if s != nil and suffix != nil:
let
sLen = s.len
suffixLen = suffix.len

if suffixLen <= sLen:
result = strncmp(cstring(addr s[sLen - suffixLen]), suffix, csize_t(suffixLen)) == 0
result = memcmp(cstring(addr s[sLen - suffixLen]), suffix, csize_t(suffixLen)) == 0

proc isObj(obj: PNimTypeV2, subclass: cstring): bool {.compilerRtl, inl.} =
result = endsWith(obj.name, subclass)
Expand Down

0 comments on commit a53a81f

Please sign in to comment.