diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-09-01 16:27:39 +0200 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-09-01 16:27:39 +0200 |
| commit | d1ff49b0fc39171859cfa781f459a2e0242c2e79 (patch) | |
| tree | 0d0853eda744e0a8c00ba255a48603642dad0788 /src/types | |
| parent | e0a9cec50023bc21c443b51433b486cbe8e52e53 (diff) | |
| download | chawan-d1ff49b0fc39171859cfa781f459a2e0242c2e79.tar.gz | |
url: reduce idna size
Instead of storing pointers to cstrings, put all of them in a single
huge string and store indices of that.
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/url.nim | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/types/url.nim b/src/types/url.nim index abb304b3..9e323847 100644 --- a/src/types/url.nim +++ b/src/types/url.nim @@ -285,14 +285,17 @@ func getIdnaTableStatus(r: Rune): IDNATableStatus = return itsValid func getIdnaMapped(r: Rune): string = - let i = uint32(r) - if i <= high(uint16): - let u = uint16(i) + let u = uint32(r) + if u <= high(uint16): + let u = uint16(u) let n = MappedMapLow.searchInMap(u) - if n != -1: - return $MappedMapLow[n].mapped - let n = MappedMapHigh.searchInMap(i) - return $MappedMapHigh[n].mapped + let idx = MappedMapLow[n].idx + let e = MappedMapData.find('\0', idx) + return MappedMapData[idx ..< e] + let n = MappedMapHigh.searchInMap(u) + let idx = MappedMapHigh[n].idx + let e = MappedMapData.find('\0', idx) + return MappedMapData[idx ..< e] func processIdna(str: string; beStrict: bool): string = # CheckHyphens = false |