Skip to content

Commit

Permalink
refactor(store): push to StoreHooks with StoreCore method (#2201)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaa authored Jan 30, 2024
1 parent c162ad5 commit 55a05fd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-dragons-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store": patch
---

Refactored `StoreCore.registerStoreHook` to use `StoreHooks._push` for gas efficiency.
8 changes: 4 additions & 4 deletions packages/store/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"file": "test/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: push 1 element",
"gasUsed": 32521
"gasUsed": 32520
},
{
"file": "test/FieldLayout.t.sol",
Expand Down Expand Up @@ -705,7 +705,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "register subscriber",
"gasUsed": 59184
"gasUsed": 56903
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -729,7 +729,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "register subscriber",
"gasUsed": 59184
"gasUsed": 56903
},
{
"file": "test/StoreCoreGas.t.sol",
Expand Down Expand Up @@ -801,7 +801,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetAndGetDynamicData",
"name": "compare: Set complex record with dynamic data using native solidity",
"gasUsed": 116821
"gasUsed": 116845
},
{
"file": "test/StoreCoreGas.t.sol",
Expand Down
2 changes: 1 addition & 1 deletion packages/store/src/StoreCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ library StoreCore {
revert IStoreErrors.Store_TableNotFound(tableId, string(abi.encodePacked(tableId)));
}

StoreHooks.push(tableId, Hook.unwrap(HookLib.encode(address(hookAddress), enabledHooksBitmap)));
StoreHooks._push(tableId, Hook.unwrap(HookLib.encode(address(hookAddress), enabledHooksBitmap)));
}

/**
Expand Down
18 changes: 9 additions & 9 deletions packages/world-modules/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallComposite",
"name": "install keys in table module",
"gasUsed": 1439780
"gasUsed": 1439483
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallGas",
"name": "install keys in table module",
"gasUsed": 1439780
"gasUsed": 1439483
},
{
"file": "test/KeysInTableModule.t.sol",
Expand All @@ -93,13 +93,13 @@
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallSingleton",
"name": "install keys in table module",
"gasUsed": 1439780
"gasUsed": 1439483
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookCompositeGas",
"name": "install keys in table module",
"gasUsed": 1439780
"gasUsed": 1439483
},
{
"file": "test/KeysInTableModule.t.sol",
Expand All @@ -117,7 +117,7 @@
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookGas",
"name": "install keys in table module",
"gasUsed": 1439780
"gasUsed": 1439483
},
{
"file": "test/KeysInTableModule.t.sol",
Expand All @@ -135,7 +135,7 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testGetKeysWithValueGas",
"name": "install keys with value module",
"gasUsed": 688698
"gasUsed": 688401
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand All @@ -153,7 +153,7 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testInstall",
"name": "install keys with value module",
"gasUsed": 688698
"gasUsed": 688401
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand All @@ -165,7 +165,7 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetAndDeleteRecordHook",
"name": "install keys with value module",
"gasUsed": 688698
"gasUsed": 688401
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand All @@ -183,7 +183,7 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetField",
"name": "install keys with value module",
"gasUsed": 688698
"gasUsed": 688401
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand Down

0 comments on commit 55a05fd

Please sign in to comment.