Repository navigation
Conversation
There was a problem hiding this comment.
Clean, mechanical refactor that moves the per-page NFT insertion logic from the free function nft::insertToken onto the new NFTokenPageEntry::insertToken member, with an explicit instantiation in a new .cpp. The moved logic (push, sort via nft::compareTokens, setFieldArray, update()) is a faithful copy of the original code, the call site in NFTokenHelpers.cpp correctly delegates to the new member, and the SLEBase.cpp test macro change (definitions → extern declarations) is explained by the accompanying MSVC C4661 cherry-pick needed once an entry gains an out-of-line member body. No behavioral changes or correctness issues found in the added lines.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
055dc6d to
86b670e
Compare
There was a problem hiding this comment.
Reviewed the last commit (NFTokenPageEntry.h/.cpp and NFTokenHelpers.cpp changes) as instructed; the SLEBase.cpp diff belongs to the separately cherry-picked, already-reviewed MSVC fix and was left out of scope. The refactor moves the per-page insert logic into NFTokenPageEntry::insertToken verbatim (same field access, sort comparator, and update() call), and NFTokenHelpers.cpp's free function now just delegates to it. I traced the logic carefully for behavioral drift (order of pushBack/sort/setFieldArray/update, move semantics, qualification of compareTokens) and found it to be an exact, faithful move with no observable change. No correctness, security, or resource issues found in the changed lines.
86b670e to
ff3ccff
Compare
There was a problem hiding this comment.
This is a clean, mechanical refactor that moves the per-page NFToken insertion logic from the free function nft::insertToken onto the new NFTokenPageEntry<ViewT>::insertToken member, gated by requires Base::kIsWritable. The moved logic (push, sort via nft::compareTokens, set field array, update) is byte-for-byte equivalent to the original, the new .cpp correctly qualifies nft::compareTokens since it's now outside the nft namespace, and the explicit instantiations for ReadView/ApplyView are consistent with the existing pattern used for findToken in the same header. The SLEBase.cpp change is explicitly called out as an unrelated cherry-picked MSVC fix (#8357) and out of scope per the PR description, so it was not reviewed. No correctness, security, or resource-management issues found in the added lines.
There was a problem hiding this comment.
Clean, well-scoped refactor that moves the per-page NFToken insert logic onto NFTokenPageEntry::insertToken, gated by requires Base::kIsWritable so it can't be called on a read-only view. The free function nft::insertToken now just delegates to the new member, and the SLEBase test instrumentation was reworked to avoid double explicit-instantiation (MSVC C4661). The logic is a direct move of the existing code with no behavior change, and the explicit-instantiation/constraint interaction looks correct for ReadView vs ApplyView. Only a minor, non-blocking observation below.
39ccc00 to
57da670
Compare
There was a problem hiding this comment.
Clean, mechanical refactor that moves the per-page NFToken insert logic from the free function nft::insertToken onto the new NFTokenPageEntry::insertToken member, with the body relocated to a new .cpp and explicit template instantiation for both ReadView and ApplyView. The new member's logic is a verbatim move of the original inline block (push, sort via nft::compareTokens, set field array, update), and the call site in NFTokenHelpers.cpp is updated accordingly — no behavioral change is apparent. The requires Base::kIsWritable constraint on a non-template member of a class template, paired with explicit instantiation for both view types, is a known C++20 pattern (constrained member functions) and appears consistent with how this codebase already structures its writable-only entry members, so it's not flagged as risky. The companion SLEBase.cpp test change is explicitly called out in the MR description as a cherry-picked prep commit from a different PR and was only skimmed accordingly. No correctness, security, or consistency issues were found in the changed lines.
nft::insertToken() first finds or creates the page for the token (and may split a full page), then adds the token to that page's NFTokens array, sorts it, and updates the page. The second part only needs the page, so it becomes NFTokenPageEntry::insertToken(STObject&&). The free function keeps the page lookup and calls the member. The member body uses nft::compareTokens(), so it goes into a new NFTokenPageEntry.cpp with explicit instantiation. The header now includes STArray.h because the explicit instantiation also instantiates the inline findToken(), which iterates an STArray. No behavior change.
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
57da670 to
fc57bad
Compare
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
…ri/rearch/nftokenpage-insertToken # Conflicts: # src/libxrpl/ledger/helpers/NFTokenHelpers.cpp
High Level Overview of Change
Adds the writable member
NFTokenPageEntry::insertToken(STObject&&): it adds the token to this page'sNFTokensarray, sorts the array withnft::compareTokens, and updates the page.nft::insertToken(view, owner, nft)stays a free function because it finds or creates (and may split) the page first; it now calls the member. The member body is in the newsrc/libxrpl/ledger/entries/NFTokenPageEntry.cppwith explicit instantiation. The header now includesSTArray.h(withIWYU pragma: keep) because explicit instantiation also instantiates the inlinefindToken(), which iterates anSTArray.Context of Change
Part of the Wrapped SLEs migration (design: step 2/3 of #7886). The per-page insert now lives on the typed, writable page wrapper, so the compiler rejects it on a read-only view or an SLE of another type. Pure refactor: no amendment, no behavior change; any observable difference is a bug.
Stacked on #8400; review only the last commit. The commit before it is a cherry-pick of the MSVC C4661 fix from #8357 (
extern templatein theSLEBasegtest). It is needed because this PR adds explicit instantiation forNFTokenPageEntry, and it drops out when #8357 merges.This PR was fully written by AI (Claude Code) under human direction; the human author reviewed the diff.
API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)Test Plan
Compile-checked (
clang++ -fsyntax-only, project flags) the newNFTokenPageEntry.cpp,NFTokenHelpers.cpp, and every .cpp that includesNFTokenPageEntry.horNFTokenHelpers.h(14/14). clang-tidy (including the standalone header check) and pre-commit are clean. No new tests. CI runs the full unit test suite.🤖 Generated with Claude Code