@@ -195,10 +195,38 @@ proc properties*(cp: Rune): UnicodeProps =
195
195
# # raw data for some of the properties, so one of
196
196
# # the auxiliary procedures must be used in conjuntion.
197
197
assert cp.int <= 0x 10FFFF
198
- let
199
- blockOffset = (propsOffsets[cp.int div blockSize]).int * blockSize
200
- idx = propsIndices[blockOffset + cp.int mod blockSize]
201
- result = propsData[idx]
198
+ when nimvm :
199
+ const N = propsIndices.len
200
+ const N2 = N div 4
201
+ const t0 = propsIndices[0 ..< N2 ]
202
+ const t1 = propsIndices[N2 ..< 2 * N2 ]
203
+ const t2 = propsIndices[2 * N2 ..< 3 * N2 ]
204
+ const t3 = propsIndices[3 * N2 ..< N]
205
+
206
+ proc getTypeIndex (sub: static [int ], ind: int ): auto =
207
+ when sub == 0 : return t0[ind]
208
+ elif sub == 1 : return t1[ind]
209
+ elif sub == 2 : return t2[ind]
210
+ else : return t3[ind]
211
+ let blockOffset = (propsOffsets[cp.int div blockSize]).int * blockSize
212
+ block :
213
+ let ind = blockOffset + cp.int mod blockSize
214
+ let ind2 = ind div N2
215
+ let j = ind mod N2
216
+ var idx = 0 'u8
217
+ case ind2
218
+ of 0 : idx = getTypeIndex (0 , j)
219
+ of 1 : idx = getTypeIndex (1 , j)
220
+ of 2 : idx = getTypeIndex (2 , j)
221
+ of 3 : idx = getTypeIndex (3 , j)
222
+ else : assert false
223
+ result = propsData[idx]
224
+ else :
225
+ block :
226
+ let
227
+ blockOffset = (propsOffsets[cp.int div blockSize]).int * blockSize
228
+ idx = propsIndices[blockOffset + cp.int mod blockSize]
229
+ result = propsData[idx]
202
230
203
231
proc unicodeCategory * (props: UnicodeProps ): UnicodeCategory {.inline .} =
204
232
# # Return category for a given `UnicodeProps`
0 commit comments