Skip to content

Commit 4e72fd1

Browse files
authored
Merge pull request #34 from dotdash/improv_codegen
Generate code that is friendlier to rustc's item_bodies_checking
2 parents f08c00c + e2c84cd commit 4e72fd1

File tree

2 files changed

+5753
-5748
lines changed

2 files changed

+5753
-5748
lines changed

scripts/unicode.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,19 @@ def gen_decomposition_tables(canon_decomp, compat_decomp, out):
315315
for table, name in tables:
316316
out.write("#[inline]\n")
317317
out.write("pub fn %s_fully_decomposed(c: char) -> Option<&'static [char]> {\n" % name)
318-
out.write(" match c {\n")
318+
# The "Some" constructor is around the match statement here, because
319+
# putting it into the individual arms would make the item_bodies
320+
# checking of rustc takes almost twice as long, and it's already pretty
321+
# slow because of the huge number of match arms and the fact that there
322+
# is a borrow inside each arm
323+
out.write(" Some(match c {\n")
319324

320325
for char, chars in sorted(table.items()):
321326
d = ", ".join("'\u{%s}'" % hexify(c) for c in chars)
322-
out.write(" '\u{%s}' => Some(&[%s]),\n" % (hexify(char), d))
327+
out.write(" '\u{%s}' => &[%s],\n" % (hexify(char), d))
323328

324-
out.write(" _ => None,\n")
325-
out.write(" }\n")
329+
out.write(" _ => return None,\n")
330+
out.write(" })\n")
326331
out.write("}\n")
327332
out.write("\n")
328333

0 commit comments

Comments
 (0)