Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
perf: A3 — length-tracked result assembly in encoderEngine
strcpy + strcat + strcat each re-scans the destination from the start
to find the null terminator. Replace with explicit strlen on each
source plus a single memcpy to copy result (including NUL).

Output bytes are unchanged.

  time ./unittest (best of 3, user):
    baseline = 114.13s
    after A3 = 113.19s
    delta    = 0.82% cumulative

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  • Loading branch information
rijnb and claude committed May 28, 2026
commit 1b01b82b73f69161798885052de04bf6f31ba52c
8 changes: 6 additions & 2 deletions mapcodelib/mapcoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1542,8 +1542,12 @@ static void encoderEngine(const enum Territory ccode, const EncodeRec* enc, cons
}
else {
getTerritoryIsoName(s, ccodeFinal, 0);
strcat(s, " ");
strcat(s, result);
{
size_t isoLen = strlen(s);
size_t resultLen = strlen(result);
s[isoLen] = ' ';
memcpy(s + isoLen + 1, result, resultLen + 1); /* +1 includes NUL */
}
}
}
if (requiredEncoder == i) {
Expand Down