[PR #1108] shader_library: move nested JSON values during parsing #1143

Open
opened 2026-11-26 20:20:14 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1108
Author: @Kadamitas
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: perf/json-subtree-moves-continued


📝 Commits (1)

  • f6ea7b6 shader_library: move nested JSON values during parsing

📊 Changes

1 file changed (+1 additions, -6 deletions)

View changed files

📝 runtime/src/shader_library.h (+1 -6)

📄 Description

Claimed in the coordination issue as: RT-JSON-SUBTREE-MOVES (claim)

What and why

The explicitly defaulted destructor suppresses the implicit move constructor of Json. Passing a parsed child to a vector with std::move therefore copies its strings and nested vectors. Growing an object or array can copy those subtrees again. Letting the compiler generate the destructor restores nonthrowing moves for both Json and JsonObjectEntry. The forward declaration still supports recursive object values.

Tested

  • shader_library_test and mods_test passed under MSVC x64, GCC 11.4 and Clang 18.1.8 with libstdc++. Clang 15 with libstdc++ 11 rejects the existing C++20 aggregate construction in emplace_back on both revisions.

  • A synthetic input had 1,200 named entries, each with a label and four arrays of six small objects. Both builds produced 181,201 nodes and the same tree digest from the 1,141,381-byte document. Five interleaved release runs per revision under MSVC gave median parse times of 71.14 ms before and 17.46 ms after. Allocation counts fell from 822,984 to 176,419. File reads and digest calculation were outside the timed region.

  • git diff --check and scripts/check_no_game_data.py runtime/src/shader_library.h passed.

  • The general translator suite ran 6,168 tests across 470 files with zero failing files.

GPUs tested: n/a, CPU-only JSON parsing.

AI-assisted: yes, Codex.

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • Translator rule documentation is inapplicable to this parser change.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1108 **Author:** [@Kadamitas](https://github.com/Kadamitas) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `perf/json-subtree-moves-continued` --- ### 📝 Commits (1) - [`f6ea7b6`](https://github.com/ubiquitarianism/leonida/commit/f6ea7b6674153893fa03f300492af116670174f8) shader_library: move nested JSON values during parsing ### 📊 Changes **1 file changed** (+1 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/shader_library.h` (+1 -6) </details> ### 📄 Description Claimed in the coordination issue as: RT-JSON-SUBTREE-MOVES ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140842004)) ### What and why The explicitly defaulted destructor suppresses the implicit move constructor of `Json`. Passing a parsed child to a vector with `std::move` therefore copies its strings and nested vectors. Growing an object or array can copy those subtrees again. Letting the compiler generate the destructor restores nonthrowing moves for both `Json` and `JsonObjectEntry`. The forward declaration still supports recursive object values. ### Tested - `shader_library_test` and `mods_test` passed under MSVC x64, GCC 11.4 and Clang 18.1.8 with libstdc++. Clang 15 with libstdc++ 11 rejects the existing C++20 aggregate construction in `emplace_back` on both revisions. - A synthetic input had 1,200 named entries, each with a label and four arrays of six small objects. Both builds produced 181,201 nodes and the same tree digest from the 1,141,381-byte document. Five interleaved release runs per revision under MSVC gave median parse times of 71.14 ms before and 17.46 ms after. Allocation counts fell from 822,984 to 176,419. File reads and digest calculation were outside the timed region. - `git diff --check` and `scripts/check_no_game_data.py runtime/src/shader_library.h` passed. - The general translator suite ran 6,168 tests across 470 files with zero failing files. GPUs tested: n/a, CPU-only JSON parsing. AI-assisted: yes, Codex. ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] Translator rule documentation is inapplicable to this parser change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1143
No description provided.