avoid threadvar (#107)

This commit is contained in:
Jacek Sieka 2024-10-01 17:12:56 +02:00 committed by GitHub
parent d5274f8e97
commit 2717b21b87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -71,18 +71,18 @@ proc readValue*[T](r: var WinregReader, value: var T)
elif T is (object or tuple):
type T = type(value)
when T.totalSerializedFields > 0:
let fields = T.fieldReadersTable(WinregReader)
const fields = T.fieldReadersTable(WinregReader)
var expectedFieldPos = 0
r.key.add ""
value.enumInstanceSerializedFields(fieldName, field):
when T is tuple:
r.key[^1] = $expectedFieldPos
var reader = fields[][expectedFieldPos].reader
var reader = fields[expectedFieldPos].reader
expectedFieldPos += 1
else:
r.key[^1] = fieldName
var reader = findFieldReader(fields[], fieldName, expectedFieldPos)
var reader = findFieldReader(fields, fieldName, expectedFieldPos)
if reader != nil:
reader(value, r)