fix: replace tascii ASCII-encoding with numeric format in write_one_object#3174
Merged
fix: replace tascii ASCII-encoding with numeric format in write_one_object#3174
Conversation
…bject
FlagData flags were saved as per-bit letter+digit strings (e.g. "a0b2 "),
requiring two tascii() calls + strcmp per flag group on every object write.
With large clan chests this caused measurable save lag (up to ~0.14 s).
Changes:
- Add FlagData::to_numeric_string() - writes four plane values as
space-separated integers ("p0 p1 p2 p3"), no per-bit iteration.
- Update FlagData::from_string() to detect and parse the new format;
legacy ASCII and packed-number formats continue to work (backward compat).
- Rewrite write_one_object() flag blocks (Affs/Anti/Nofl/Extr/Wear) to
use direct FlagData::operator!= comparison and to_numeric_string(),
eliminating temporary char buffers and O(120) tascii loops per save.
- Fix CLAUDE.md: document Release as the correct CMAKE_BUILD_TYPE for
development builds (Test is CI/Docker only).
Fixes #3165
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #3165
FlagData::to_numeric_string()that serializes four plane values as space-separated integers ("p0 p1 p2 p3"), eliminating per-bit iteration andsnprintfloops.FlagData::from_string()to detect and parse the new format; legacy ASCII letter+digit encoding and old packed-number format continue to work (full backward compatibility with existing saves).write_one_object()(Affs / Anti / Nofl / Extr / Wear) to use directFlagData::operator!=+to_numeric_string()— no temporarycharbuffers, notascii+strcmpround-trips.CLAUDE.md: documentsReleaseas the correctCMAKE_BUILD_TYPEfor development (Testis CI/Docker only).Before
Each object write called
tascii()×10 (5 flag groups × 2: object + proto), each doing 4×30 = 120 iterations withstrlen()/snprintf()per set bit, thenstrcmp.After
Each flag group: one
operator!=(4 integer comparisons), and on difference — oneto_numeric_string()(4std::to_stringcalls). No temporary buffers.Test plan
to_numeric_string(), new numericfrom_string(), round-trips, and legacy format compatibility (FlagData.*suite)🤖 Generated with Claude Code