refactor(libc): read toupper and tolower from the case tables #14022

Merged
romainhedouin merged 1 commit from upstream-pr/14022 into main 2026-11-14 05:58:12 +00:00
romainhedouin commented 2026-10-31 16:18:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by romainhedouin on 2026-10-31T16:18:07Z.


What

toupper and tolower looked up the C++ locale on every call. The same mapping is already in g_upperTable and g_lowerTable, so they now read from those tables. The results are the same.

Tested

  • macOS (Apple M4, arm64): a small standalone program ran the old and new function side by side on about 800,000 inputs, including values outside the valid range. No differences.
  • tools/check_conventions.py passes.
  • Not tested: the full build, the GuestCharacter and GuestRuneLocale tests, and any game. This Mac can't run the x86-64 build.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5099321647 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14022). Originally posted by [romainhedouin](https://github.com/romainhedouin) on 2026-10-31T16:18:07Z. --- ### What `toupper` and `tolower` looked up the C++ locale on every call. The same mapping is already in `g_upperTable` and `g_lowerTable`, so they now read from those tables. The results are the same. ### Tested - macOS (Apple M4, arm64): a small standalone program ran the old and new function side by side on about 800,000 inputs, including values outside the valid range. No differences. - `tools/check_conventions.py` passes. - Not tested: the full build, the `GuestCharacter` and `GuestRuneLocale` tests, and any game. This Mac can't run the x86-64 build. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-31 16:21:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T16:21:25Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The source change is consistent with the existing classic-locale case tables, but this perf PR does not include the performance report required by the repository.

What I ran

Reviewed head 2d5f3cad64a75872bbb78ec6929ac526f99e5615 against base 474030e58424fefdb65e5df9f3820810fbb4553c; the base is an ancestor of the head and the merge preview is clean. Environment: Debian GNU/Linux 12, Python 3.11.2, GCC 12.2.0. No project build or compilation was run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14022
git diff --check 474030e58424fefdb65e5df9f3820810fbb4553c...2d5f3cad64a75872bbb78ec6929ac526f99e5615
gh pr checks 14022 -R boykopovar/AnyPS5
nl -ba core/libs/prx/libc/src/LocaleSupport.cpp | sed -n '325,370p'

Results

Check Result
Diff check Passed
Conventions and PR template Passed locally and in hosted CI
Merge-base check Base is an ancestor of head
Hosted checks conventions, intake, and labels passed; no build or tests ran
Performance report Missing required paired trace summaries, traces, and digest
Source inspection ConvertCharacter validates the argument, preserves negative values, then indexes the existing lower/upper tables at value + 1
Unedited command output
All conventions checks passed.

The gh pr checks output on this head was:

conventions	pass	16s	https://github.com/boykopovar/AnyPS5/actions/runs/41219016723/job/124589491532
intake	pass	19s	https://github.com/boykopovar/AnyPS5/actions/runs/41219016720/job/124589491493
labels	pass	13s	https://github.com/boykopovar/AnyPS5/actions/runs/41219016761/job/124589491797

Findings

Blocking

  • Required performance evidence is absent. The PR title is perf(libc): ..., and the description reports timing gains, but it contains no paired aps5-summary.jsonl lines from main and this change for the same scene and machine, no corresponding traces, and no tools/trace_digest.py output. Please add that matched report, or remove the performance claim and retitle the PR to reflect a non-performance change.

Non-blocking

  • No additional source-level correctness issue was identified in the one-line change. The stated standalone benchmark is author-reported and was not independently reproduced here.

Sources

Not verified

  • No local build, C++ tests, or benchmark was run. The hosted run for this head did not include build or test jobs.
  • The reported macOS timings and equivalence experiment are from the PR description and were not independently reproduced.

To get this to a good state

Add the matched baseline/change summaries, trace files, and digest output, or remove the performance claim and retitle the PR. I will rerun the relevant checks and review the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5723745262 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14022#pullrequestreview-5723745262). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T16:21:25Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The source change is consistent with the existing classic-locale case tables, but this `perf` PR does not include the performance report required by the repository. ## What I ran Reviewed head `2d5f3cad64a75872bbb78ec6929ac526f99e5615` against base `474030e58424fefdb65e5df9f3820810fbb4553c`; the base is an ancestor of the head and the merge preview is clean. Environment: Debian GNU/Linux 12, Python 3.11.2, GCC 12.2.0. No project build or compilation was run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14022 git diff --check 474030e58424fefdb65e5df9f3820810fbb4553c...2d5f3cad64a75872bbb78ec6929ac526f99e5615 gh pr checks 14022 -R boykopovar/AnyPS5 nl -ba core/libs/prx/libc/src/LocaleSupport.cpp | sed -n '325,370p' ``` ## Results | Check | Result | |---|---| | Diff check | Passed | | Conventions and PR template | Passed locally and in hosted CI | | Merge-base check | Base is an ancestor of head | | Hosted checks | `conventions`, `intake`, and `labels` passed; no build or tests ran | | Performance report | Missing required paired trace summaries, traces, and digest | | Source inspection | `ConvertCharacter` validates the argument, preserves negative values, then indexes the existing lower/upper tables at `value + 1` | <details><summary>Unedited command output</summary> ```text All conventions checks passed. ``` The `gh pr checks` output on this head was: ```text conventions pass 16s https://github.com/boykopovar/AnyPS5/actions/runs/41219016723/job/124589491532 intake pass 19s https://github.com/boykopovar/AnyPS5/actions/runs/41219016720/job/124589491493 labels pass 13s https://github.com/boykopovar/AnyPS5/actions/runs/41219016761/job/124589491797 ``` </details> ## Findings ### Blocking - **Required performance evidence is absent.** The PR title is `perf(libc): ...`, and the description reports timing gains, but it contains no paired `aps5-summary.jsonl` lines from `main` and this change for the same scene and machine, no corresponding traces, and no `tools/trace_digest.py` output. Please add that matched report, or remove the performance claim and retitle the PR to reflect a non-performance change. ### Non-blocking - No additional source-level correctness issue was identified in the one-line change. The stated standalone benchmark is author-reported and was not independently reproduced here. ## Sources - [Repository performance-report rule at base `474030e`](https://github.com/boykopovar/AnyPS5/blob/474030e58424fefdb65e5df9f3820810fbb4553c/CONTRIBUTING.md) - [Changed `ConvertCharacter` implementation at head `2d5f3cad`](https://github.com/boykopovar/AnyPS5/blob/2d5f3cad64a75872bbb78ec6929ac526f99e5615/core/libs/prx/libc/src/LocaleSupport.cpp#L330-L366) ## Not verified - No local build, C++ tests, or benchmark was run. The hosted run for this head did not include build or test jobs. - The reported macOS timings and equivalence experiment are from the PR description and were not independently reproduced. ## To get this to a good state Add the matched baseline/change summaries, trace files, and digest output, or remove the performance claim and retitle the PR. I will rerun the relevant checks and review the updated head.
MarcZX10 commented 2026-10-31 16:54:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T16:54:27Z.

Review: APPROVED


Re-checked — new head, looks good

The updated refactor title and description no longer make an unsupported performance claim, and the one-line mapping preserves the existing validated classic-locale table behavior.

What I ran

Reviewed head c2e509fa02e6be7ae636fc06e94737494be92d4d against base 474030e58424fefdb65e5df9f3820810fbb4553c; the live merge preview is clean. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5. I did not invoke a compiler or build locally.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14022 --output-dir /tmp/anyps5-14022-update-precheck
gh pr checks 14022 -R boykopovar/AnyPS5

I also inspected the exact one-line diff and MakeCaseTable/ConvertCharacter at the PR head. Negative values are returned before indexing; values 0–255 map to indices 1–256 of the 257-entry table.

Results

Check Result
Diff check Passed
Conventions and PR template Passed locally and in hosted CI
Live dependency and mergeability preview Passed; clean against base 474030e58424fefdb65e5df9f3820810fbb4553c
Hosted CI conventions and labels passed on the exact head; no build or test job ran
ABI/test-quality helpers Unavailable in the isolated precheck checkout; no exports or Python tests changed
Author-reported equivalence check The PR description reports old/new comparisons across about 800,000 inputs, including out-of-range values; I did not independently run that program
Local build and project tests Not run
Unedited local precheck output

Conventions stdout:

All conventions checks passed.

ABI helper stderr:

/usr/bin/python3: can't open file '/tmp/anyps5-14022-update-precheck/head-c2e509fa02e6-49348a5e/tools/pr_abi_audit.py': [Errno 2] No such file or directory

Test-quality helper stderr:

/usr/bin/python3: can't open file '/tmp/anyps5-14022-update-precheck/head-c2e509fa02e6-49348a5e/tools/pr_test_quality.py': [Errno 2] No such file or directory

The precheck recorded diff_check, conventions_and_pr_template, and live_dependency_and_mergeability_check as passed. The successful diff check produced no output.

Findings

Blocking

None found in the updated head.

Non-blocking

None.

Sources

Not verified

  • I did not independently reproduce the author's standalone equivalence run.
  • No C++ build or project test suite was run locally; hosted CI for this head contained only conventions and labels.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5723885135 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14022#pullrequestreview-5723885135). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T16:54:27Z. **Review:** APPROVED --- # Re-checked — new head, looks good The updated refactor title and description no longer make an unsupported performance claim, and the one-line mapping preserves the existing validated classic-locale table behavior. ## What I ran Reviewed head `c2e509fa02e6be7ae636fc06e94737494be92d4d` against base `474030e58424fefdb65e5df9f3820810fbb4553c`; the live merge preview is clean. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5. I did not invoke a compiler or build locally. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14022 --output-dir /tmp/anyps5-14022-update-precheck gh pr checks 14022 -R boykopovar/AnyPS5 ``` I also inspected the exact one-line diff and `MakeCaseTable`/`ConvertCharacter` at the PR head. Negative values are returned before indexing; values 0–255 map to indices 1–256 of the 257-entry table. ## Results | Check | Result | |---|---| | Diff check | Passed | | Conventions and PR template | Passed locally and in hosted CI | | Live dependency and mergeability preview | Passed; clean against base `474030e58424fefdb65e5df9f3820810fbb4553c` | | Hosted CI | `conventions` and `labels` passed on the exact head; no build or test job ran | | ABI/test-quality helpers | Unavailable in the isolated precheck checkout; no exports or Python tests changed | | Author-reported equivalence check | The PR description reports old/new comparisons across about 800,000 inputs, including out-of-range values; I did not independently run that program | | Local build and project tests | Not run | <details><summary>Unedited local precheck output</summary> Conventions stdout: ```text All conventions checks passed. ``` ABI helper stderr: ```text /usr/bin/python3: can't open file '/tmp/anyps5-14022-update-precheck/head-c2e509fa02e6-49348a5e/tools/pr_abi_audit.py': [Errno 2] No such file or directory ``` Test-quality helper stderr: ```text /usr/bin/python3: can't open file '/tmp/anyps5-14022-update-precheck/head-c2e509fa02e6-49348a5e/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` The precheck recorded `diff_check`, `conventions_and_pr_template`, and `live_dependency_and_mergeability_check` as passed. The successful diff check produced no output. </details> ## Findings ### Blocking None found in the updated head. ### Non-blocking None. ## Sources - [Case table and conversion implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/c2e509fa02e6be7ae636fc06e94737494be92d4d/core/libs/prx/libc/src/LocaleSupport.cpp#L548-L568) - [Performance-report requirement at current base](https://github.com/boykopovar/AnyPS5/blob/474030e58424fefdb65e5df9f3820810fbb4553c/CONTRIBUTING.md#L69) ## Not verified - I did not independently reproduce the author's standalone equivalence run. - No C++ build or project test suite was run locally; hosted CI for this head contained only conventions and labels.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!14022
No description provided.