Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mapcode-foundation/mapcode-cpp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.5.6
Choose a base ref
...
head repository: mapcode-foundation/mapcode-cpp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 19 commits
  • 9 files changed
  • 2 contributors

Commits on May 28, 2026

  1. Fix critical and major code review issues

    - Replace memcmp-based NaN/Inf detection with isnan()/isinf() from <math.h>
      (portable, correct for all NaN bit patterns, and now checks latDeg for Inf too)
    - Fix off-by-one in encodeLatLonToSelectedMapcode: > should be >= for index bound
    - Remove always-false ASSERT after *s=0 in encodeExtension
    - Fix convertFromAbjad/convertToAbjad to null-check strchr return before arithmetic
    - Allow TERRITORY_NONE/TERRITORY_UNKNOWN in encodeLatLonToSingleMapcode per docs
    - Fix convertUtf16ToUtf8 to return start pointer instead of post-null end pointer
    - Explicitly initialize GLOBAL_MAKEISO_PTR (was accidentally correct via NULL)
    - Replace sprintf with snprintf in convertToRoman (mapcode_legacy.c)
    - Change UWORD from unsigned short int to uint16_t; add #include <stdint.h>
    - Replace magic constant 128 with MAX_MAPCODE_RESULT_ASCII_LEN in encoderEngine
    - Add regression tests for all fixed bugs in testBugFixes()
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    47e0d32 View commit details
    Browse the repository at this point in the history
  2. updagted version

    rijnb committed May 28, 2026
    Configuration menu
    Copy the full SHA
    ea028ff View commit details
    Browse the repository at this point in the history
  3. Fix critical and major code review issues

    - Replace memcmp-based NaN/Inf detection with isnan()/isinf() from <math.h>
      (portable, correct for all NaN bit patterns, and now checks latDeg for Inf too)
    - Fix off-by-one in encodeLatLonToSelectedMapcode: > should be >= for index bound
    - Remove always-false ASSERT after *s=0 in encodeExtension
    - Fix convertFromAbjad/convertToAbjad to null-check strchr return before arithmetic
    - Allow TERRITORY_NONE/TERRITORY_UNKNOWN in encodeLatLonToSingleMapcode per docs
    - Fix convertUtf16ToUtf8 to return start pointer instead of post-null end pointer
    - Explicitly initialize GLOBAL_MAKEISO_PTR (was accidentally correct via NULL)
    - Replace sprintf with snprintf in convertToRoman (mapcode_legacy.c)
    - Change UWORD from unsigned short int to uint16_t; add #include <stdint.h>
    - Replace magic constant 128 with MAX_MAPCODE_RESULT_ASCII_LEN in encoderEngine
    - Add regression tests for all fixed bugs in testBugFixes()
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    a21ef29 View commit details
    Browse the repository at this point in the history
  4. updagted version

    rijnb committed May 28, 2026
    Configuration menu
    Copy the full SHA
    794e31f View commit details
    Browse the repository at this point in the history
  5. docs: design spec for mapcodelib speed optimization

    Two-phase plan (A: local hot-path cleanups; B: precomputed companion
    tables) targeting 20-50% wall-time reduction on `time ./unittest` at -O3,
    preserving bit-exact output, strict portable C99/C11, and no runtime/heap
    growth.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    740bfec View commit details
    Browse the repository at this point in the history
  6. docs: implementation plan for mapcodelib speed optimization

    Step-by-step plan for Tasks 1-10 (baseline → A1-A5 → B3-B5 → results),
    each with explicit file/line targets, code blocks, expected outputs,
    and per-step commits.
    
    Also fixes a small inaccuracy in the spec: RECORD_CODEX stores the
    computed coDex value (10*(c/5)+(c%5+1)), not the raw flags & 31.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    9813f71 View commit details
    Browse the repository at this point in the history
  7. chore: pin perf baseline for feat/optimize

    Measured `time ./unittest` on -O3 build (best of 3 runs):
      user time = T0 = 114.13s
    
    All subsequent perf commits on this branch quote their best user time
    and the cumulative delta vs. this baseline.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    f1cb736 View commit details
    Browse the repository at this point in the history
  8. perf: A1 — cache flags per loop iteration in hot paths

    In encoderEngine and decoderEngine inner loops, read
    TERRITORY_BOUNDARIES[i].flags once per iteration into a const local and
    extract bit fields from it, instead of using flag-extraction macros that
    each re-dereference the same memory. Same change in firstNamelessRecord
    and countNamelessRecords.
    
    Bit-exact: macros stay defined and used in cold paths; only the inner
    loop body call sites were rewritten to local reads.
    
      time ./unittest (best of 3, user):
        baseline (T0) = 114.13s
        after A1 (T2) = 111.78s
        delta         = 2.06% cumulative
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    430bbba View commit details
    Browse the repository at this point in the history
  9. perf: A2 — reorder fitsInsideBoundaries to test longitude first

    Most territory rectangles are narrower in longitude than in latitude
    relative to their bounding ranges, so testing longitude first short-
    circuits faster on the typical reject case.
    
      time ./unittest (best of 3, user):
        baseline = 114.13s
        after A2  = 121.10s
        delta     = -6.11% cumulative (regression vs baseline)
    
    Note: result is slower than A1 (T2=112.21s); the lon-first ordering
    did not yield a speedup on this benchmark — likely because isInRange
    carries more overhead than the simple comparison it replaces.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    b9b3f2c View commit details
    Browse the repository at this point in the history
  10. revert: A2 — reorder fitsInsideBoundaries (caused regression)

    Reverts b9b3f2c. isInRange() wraps longitude and has higher overhead
    than simple comparisons; testing it first regressed user time by ~7.9s
    vs A1 baseline. Reverting to lat-first ordering.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    5246c79 View commit details
    Browse the repository at this point in the history
  11. 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>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    1b01b82 View commit details
    Browse the repository at this point in the history
  12. perf: A4 — single division per iteration in encodeBase31

    Compute quotient once, derive remainder via subtraction so the loop
    has one division-class op per character rather than two.
    
      time ./unittest (best of 3, user):
        baseline = 114.13s
        after A4  = 114.35s
        delta     = -0.19% cumulative (within noise floor)
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    753c337 View commit details
    Browse the repository at this point in the history
  13. perf: B1+B2+B3 — add precomputed companion tables and one-time init

    Static tables RECORD_CODEX / RECORD_REC_TYPE / RECORD_KIND /
    RECORD_HEADER_LETTER / RECORD_SMART_DIV precomputed once from
    TERRITORY_BOUNDARIES.flags. Per-territory TERRITORY_FIRST_NAMELESS /
    TERRITORY_NAMELESS_COUNT replace linear nameless scans later.
    
    This commit only defines the tables and calls initCompanionTables at
    the top of encodeLatLonToMapcodes_internal and decoderEngine. Hot loops
    still use the existing macros; the switch happens in B4.
    
    Memory footprint: ~74 KB of additional static data (.bss).
    
      time ./unittest (best of 3, user):
        baseline = 114.13s
        after B3 = 109.99s
        delta    = -3.6% cumulative
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    554af29 View commit details
    Browse the repository at this point in the history
  14. perf: B4 — hot loops read from precomputed companion tables

    Replace per-iteration mask/shift extractions in encoderEngine,
    decoderEngine, firstNamelessRecord, countNamelessRecords with direct
    reads from RECORD_KIND / RECORD_CODEX / RECORD_REC_TYPE /
    RECORD_HEADER_LETTER. The companion tables are byte-sized so each
    field is a single byte load with friendlier cache behavior than
    re-deriving from the 4-byte flags field each iteration.
    
    Inner j-loops in decoderEngine also switch to RECORD_KIND[j] &
    KIND_BIT_RESTRICTED instead of the IS_RESTRICTED(j) macro.
    
    Values are derived from the same macros they replace (see B3 init);
    output is bit-exact.
    
      time ./unittest (best of 3, user):
        baseline = 114.13s
        after B4 = 99.40s
        delta    = -13.1% cumulative
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    3416f87 View commit details
    Browse the repository at this point in the history
  15. perf: B5 — DEBUG-build sanity check for companion tables

    Under -DDEBUG, initCompanionTables asserts that every precomputed value
    matches the macro-derived one. Free correctness guard during development;
    zero cost in release.
    
    Verified: both -O3 and -O0 -DDEBUG builds pass the unit suite.
    
      time ./unittest -O3 (best of 3, user):
        baseline = 114.13s
        after B5 = 99.73s
        delta    = -12.6% cumulative
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    2cdf52b View commit details
    Browse the repository at this point in the history
  16. docs: record final perf results for feat/optimize branch

    Appends results table to design spec. Final speedup: ~12.6% on
    `time ./unittest` at -O3. Target was 20-50%; achieved 12.6%.
    Primary driver: B4 companion-table hot-loop reads. A2 reverted
    (regression), A4/A5 no-ops at -O3. Binary size delta: +2240 bytes.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    9f99fa8 View commit details
    Browse the repository at this point in the history
  17. docs: add perf results table to docs/superpowers

    Per-commit timing table for feat/optimize branch with notes on why
    each optimization landed, regressed, or was a no-op.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    rijnb and claude committed May 28, 2026
    Configuration menu
    Copy the full SHA
    d5778ab View commit details
    Browse the repository at this point in the history
  18. Merge branch 'feat/optimize'

    rijnb committed May 28, 2026
    Configuration menu
    Copy the full SHA
    400c405 View commit details
    Browse the repository at this point in the history
  19. updated README

    rijnb committed May 28, 2026
    Configuration menu
    Copy the full SHA
    85b4d82 View commit details
    Browse the repository at this point in the history
Loading