Skip to content

Commit 27f0a9b

Browse files
committed
up
1 parent c3237df commit 27f0a9b

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

contracts/utils/Memory.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ library Memory {
5252
*
5353
* NOTE: Will return `0x00` if `offset` is larger or equal to `32`.
5454
*/
55-
function extractByte(Pointer ptr, uint256 offset) internal pure returns (bytes1 v) {
56-
bytes32 word = extractWord(ptr);
55+
function loadByte(Pointer ptr, uint256 offset) internal pure returns (bytes1 v) {
56+
bytes32 word = load(ptr);
5757
assembly ("memory-safe") {
5858
v := byte(offset, word)
5959
}
6060
}
6161

6262
/// @dev Extracts a `bytes32` from a `Pointer`.
63-
function extractWord(Pointer ptr) internal pure returns (bytes32 v) {
63+
function load(Pointer ptr) internal pure returns (bytes32 v) {
6464
assembly ("memory-safe") {
6565
v := mload(ptr)
6666
}

test/utils/Memory.t.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ contract MemoryTest is Test {
3636
}
3737
}
3838

39-
function testExtractByte(uint256 seed, uint256 index, bytes32 value) public pure {
39+
function testLoadByte(uint256 seed, uint256 index, bytes32 value) public pure {
4040
index = bound(index, 0, 31);
4141
Memory.Pointer ptr = bytes32(bound(seed, START_PTR, END_PTR)).asPointer();
4242

@@ -48,15 +48,15 @@ contract MemoryTest is Test {
4848
assembly ("memory-safe") {
4949
expected := byte(index, value)
5050
}
51-
assertEq(ptr.extractByte(index), expected);
51+
assertEq(ptr.loadByte(index), expected);
5252
}
5353

54-
function testExtractWord(uint256 seed, bytes32 value) public pure {
54+
function testLoad(uint256 seed, bytes32 value) public pure {
5555
Memory.Pointer ptr = bytes32(bound(seed, START_PTR, END_PTR)).asPointer();
5656
assembly ("memory-safe") {
5757
mstore(ptr, value)
5858
}
59-
assertEq(ptr.extractWord(), value);
59+
assertEq(ptr.load(), value);
6060
}
6161

6262
function testSymbolicAddOffset(uint256 seed, uint256 offset) public pure {

test/utils/Memory.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ describe('Memory', function () {
2626
});
2727
});
2828

29-
it('extractWord extracts a word', async function () {
29+
it('load extracts a word', async function () {
3030
const ptr = await this.mock.$getFreePointer();
31-
await expect(this.mock.$extractWord(ptr)).to.eventually.equal(ethers.toBeHex(0, 32));
31+
await expect(this.mock.$load(ptr)).to.eventually.equal(ethers.toBeHex(0, 32));
3232
});
3333

34-
it('extractByte extracts a byte', async function () {
34+
it('loadByte extracts a byte', async function () {
3535
const ptr = await this.mock.$getFreePointer();
36-
await expect(this.mock.$extractByte(ptr, 0)).to.eventually.equal(ethers.toBeHex(0, 1));
36+
await expect(this.mock.$loadByte(ptr, 0)).to.eventually.equal(ethers.toBeHex(0, 1));
3737
});
3838

3939
it('contentPointer', async function () {

0 commit comments

Comments
 (0)