Misc perf fixes (toml, yaml) - #713
Conversation
|
I ran JAIPilot Cloud against this exact PR head. It found one additional TOML allocation cleanup: compact underscores in place in the parser-owned token buffer instead of allocating a second char array. The same 113 focused parser tests passed before and after, including a long token that forces buffer growth and a following token that checks for corruption. Five fixed allocation batches on a 10,000-digit underscored integer moved from 551,104 to 524,416 allocated bytes per parse, and the full 1,558-test clean build passed. PR directly onto this source branch: pjfanning#13 Only the underscore slow path changes; ordinary integer tokens are untouched, and the long-token fixture is not presented as a production-throughput claim. |
…integer literals (#13) Co-authored-by: jaipilot[bot] <273169020+jaipilot[bot]@users.noreply.github.com>
|
Thanks @skrcode - that change looks sensible and since it improves the change in my PR, it makes sense to merge it into this. |
suggested by Claude AI
Performance Fixes
yaml/YAMLGenerator.java:691String.valueOf(v.toString())→v.toString()— eliminated redundant String conversion on BigInteger writesyaml/YAMLGenerator.java:327Long.valueOf(id).toString()→Long.toString(id)— avoids unnecessary boxingyaml/YAMLGenerator.java:799Optional.of().map().Anchor()chain → directnew Anchor(id.toString())toml/TomlParser.java:328-336new String().replace().toCharArray()(3 allocations) with single-pass in-place char copy skipping underscorestoml/TomlParser.java:450indexOf('_')guard before.replace("_", "")— avoids unnecessary String copy on the common case (no underscores)