diff --git a/.changeset/rare-dragons-walk.md b/.changeset/rare-dragons-walk.md new file mode 100644 index 0000000000..7dd50548f9 --- /dev/null +++ b/.changeset/rare-dragons-walk.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/store": patch +--- + +Refactored `StoreCore.registerStoreHook` to use `StoreHooks._push` for gas efficiency. diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 9271bb43e3..5bb366a751 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -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", @@ -705,7 +705,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "register subscriber", - "gasUsed": 59184 + "gasUsed": 56903 }, { "file": "test/StoreCoreGas.t.sol", @@ -729,7 +729,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "register subscriber", - "gasUsed": 59184 + "gasUsed": 56903 }, { "file": "test/StoreCoreGas.t.sol", @@ -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", diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 828258f2fa..57155f976f 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -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))); } /** diff --git a/packages/world-modules/gas-report.json b/packages/world-modules/gas-report.json index 74d7596968..5bd322584c 100644 --- a/packages/world-modules/gas-report.json +++ b/packages/world-modules/gas-report.json @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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",