Make classRegistry use hashes instead of strings as keys for faster lookup

Up version to 0.7.16
This commit is contained in:
Evgeny Zuev 2018-08-28 14:05:33 +07:00 • committed by Ruslan Mustakov
commit ceaf66a34c
9 changed files with 101 additions and 23 deletions

View file

@ -66,6 +66,8 @@ type
GodotString* {.byref.} = object
data: array[sizeof(int), byte]
cwchar_t* {.importc: "wchar_t", nodecl.} = object
GodotCharString* {.byref.} = object
data: array[sizeof(int), byte]
@ -305,3 +307,6 @@ type
GodotClassConstructor* = proc (): ptr GodotObject {.
noconv, gcsafe, locks: 0, raises: [], tags: [].}
template offset*[T](p: ptr T, offset: int): ptr T =
cast[ptr T](cast[ByteAddress](p) +% (offset * sizeof(T)))

View file

@ -3,9 +3,6 @@
import godotinternaltypes, gdnativeapi
import core.godotcoretypes
proc offset[T](p: ptr T, offset: int): ptr T {.inline.} =
cast[ptr T](cast[ByteAddress](p) +% (offset * sizeof(T)))
template genPoolArrayAPI(ArrayT, initIdent, DataT,
newProc, newCopyProc, newWithArrayProc, appendProc,
appendArrayProc, insertProc, invertProc, pushBackProc,

View file

@ -22,6 +22,12 @@ proc `&`*(self, b: GodotString): GodotString {.inline.} =
proc deinit*(self: var GodotString) {.inline.} =
getGDNativeAPI().stringDestroy(self)
proc len*(self: GodotString): cint {.inline.} =
getGDNativeAPI().stringLength(self)
proc dataPtr*(self: GodotString): ptr cwchar_t {.inline.} =
getGDNativeAPI().stringWideStr(self)
proc `$`*(self: GodotString): string =
## Converts the ``GodotString`` into Nim string
var charStr = getGDNativeAPI().stringUtf8(self)