Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary layer copy #2567

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
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
16 changes: 9 additions & 7 deletions nimbus/db/aristo/aristo_tx/tx_frame.nim
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,16 @@ proc txFrameCommit*(
let db = ? tx.getDbDescFromTopTx()

# Pop layer from stack and merge database top layer onto it
let merged = db.stack[^1]
db.stack.setLen(db.stack.len-1)
if not db.top.isEmpty():
# Only call `layersMergeOnto()` if layer is empty
db.top.layersMergeOnto merged[]
let merged = db.stack.pop()
if not merged.isEmpty():
# No need to update top if we popped an empty layer
if not db.top.isEmpty():
# Only call `layersMergeOnto()` if layer is empty
db.top.layersMergeOnto merged[]

# Install `merged` stack top layer and update stack
db.top = merged

# Install `merged` stack top layer and update stack
db.top = merged
db.txRef = tx.parent
if 0 < db.stack.len:
db.txRef.txUid = db.getTxUid
Expand Down
Loading