Skip to content

Commit c1978f6

Browse files
committed
Open up 0 as a niche
1.3% faster. :)
1 parent c93c228 commit c1978f6

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

make-tzdb/generate_lookup_table.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def convert(stdin, stdout):
152152
for entry in table:
153153
match entry:
154154
case (name, canon):
155-
print(f' V{idx} = {idx},', file=stdout)
155+
print(f' V{idx} = {idx + 1},', file=stdout)
156156
idx += 1
157157
entry_count = idx
158158
print('}', file=stdout)
@@ -170,23 +170,34 @@ def convert(stdin, stdout):
170170
print('];', file=stdout)
171171
print(file=stdout)
172172

173-
print(f'const NAMES: [&[u8]; {entry_count}] = [', file=stdout)
173+
print(f'const NAMES: [&[u8]; {entry_count + 1}] = [', file=stdout)
174+
print(f' b"",', file=stdout)
174175
for entry in table:
175176
match entry:
176177
case (name, canon):
177178
print(f' b"{name}",', file=stdout)
178179
print('];', file=stdout)
179180
print(file=stdout)
180181

181-
print(f'pub(crate) const TIME_ZONES: [&TimeZoneRef<\'static>; {entry_count}] = [', file=stdout)
182+
print(f'pub(crate) const TIME_ZONES: [&TimeZoneRef<\'static>; {entry_count + 1}] = [', file=stdout)
183+
for entry in table:
184+
match entry:
185+
case (name, canon):
186+
print(f' &tzdata::{canon},', file=stdout)
187+
break
182188
for entry in table:
183189
match entry:
184190
case (name, canon):
185191
print(f' &tzdata::{canon},', file=stdout)
186192
print('];', file=stdout)
187193
print(file=stdout)
188194

189-
print(f'pub(crate) const RAW_TIME_ZONES: [&[u8]; {entry_count}] = [', file=stdout)
195+
print(f'pub(crate) const RAW_TIME_ZONES: [&[u8]; {entry_count + 1}] = [', file=stdout)
196+
for entry in table:
197+
match entry:
198+
case (name, canon):
199+
print(f' raw_tzdata::{canon},', file=stdout)
200+
break
190201
for entry in table:
191202
match entry:
192203
case (name, canon):

0 commit comments

Comments
 (0)