From 5bb7219f4b8d5ce22169d5139bd1c07d7b2fcafd Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Thu, 7 Jun 2018 11:43:17 -0700 Subject: Camelcase in memCopy --- .../current/test/TestLibMem/TestLibMem.sol | 8 +++--- .../contracts/current/utils/LibBytes/LibBytes.sol | 4 +-- .../src/contracts/current/utils/LibMem/LibMem.sol | 32 +++++++++++----------- packages/contracts/test/libraries/lib_mem.ts | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'packages/contracts') diff --git a/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol b/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol index 076bee24c..b7e2e06b8 100644 --- a/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol +++ b/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol @@ -25,11 +25,11 @@ contract TestLibMem is { /// @dev Copies a block of memory from one location to another. - /// @param mem Memory contents we want to apply memcpy to + /// @param mem Memory contents we want to apply memCopy to /// @param dest Destination offset into . /// @param source Source offset into . /// @param length Length of bytes to copy from to - /// @return mem Memory contents after calling memcpy. + /// @return mem Memory contents after calling memCopy. function testMemcpy( bytes mem, uint256 dest, @@ -47,8 +47,8 @@ contract TestLibMem is // Get pointer to memory contents uint256 offset = getMemAddress(mem) + 32; - // Execute memcpy adjusted for memory array location - memcpy(offset + dest, offset + source, length); + // Execute memCopy adjusted for memory array location + memCopy(offset + dest, offset + source, length); // Return modified memory contents return mem; diff --git a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol index 282455ea0..4f9e2f152 100644 --- a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol +++ b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol @@ -311,7 +311,7 @@ contract LibBytes is // Allocate memory and copy value to result result = new bytes(nestedBytesLength); - memcpy( + memCopy( getMemAddress(result) + 32, // +32 skips array length getMemAddress(b) + index + 32, nestedBytesLength @@ -340,7 +340,7 @@ contract LibBytes is ); // Copy into - memcpy( + memCopy( getMemAddress(b) + 32 + index, // +32 to skip length of getMemAddress(input), // includes length of input.length + 32 // +32 bytes to store length diff --git a/packages/contracts/src/contracts/current/utils/LibMem/LibMem.sol b/packages/contracts/src/contracts/current/utils/LibMem/LibMem.sol index 960850725..6afb9973a 100644 --- a/packages/contracts/src/contracts/current/utils/LibMem/LibMem.sol +++ b/packages/contracts/src/contracts/current/utils/LibMem/LibMem.sol @@ -39,7 +39,7 @@ contract LibMem /// @param dest memory address to copy bytes to. /// @param source memory address to copy bytes from. /// @param length number of bytes to copy. - function memcpy( + function memCopy( uint256 dest, uint256 source, uint256 length @@ -81,42 +81,42 @@ contract LibMem if (source > dest) { assembly { // Record the total number of full words to copy - let nwords := div(length, 32) + let nWords := div(length, 32) - // We subtract 32 from `send` and `dend` because it + // We subtract 32 from `sEnd` and `dEnd` because it // is easier to compare with in the loop, and these // are also the addresses we need for copying the // last bytes. length := sub(length, 32) - let send := add(source, length) - let dend := add(dest, length) + let sEnd := add(source, length) + let dEnd := add(dest, length) // Remember the last 32 bytes of source // This needs to be done here and not after the loop // because we may have overwritten the last bytes in // source already due to overlap. - let last := mload(send) + let last := mload(sEnd) // Copy whole words front to back - for {let i := 0} lt(i, nwords) {i := add(i, 1)} { + for {let i := 0} lt(i, nWords) {i := add(i, 1)} { mstore(dest, mload(source)) source := add(source, 32) dest := add(dest, 32) } // Write the last 32 bytes - mstore(dend, last) + mstore(dEnd, last) } } else { assembly { // Record the total number of full words to copy - let nwords := div(length, 32) + let nWords := div(length, 32) - // We subtract 32 from `send` and `dend` because those + // We subtract 32 from `sEnd` and `dEnd` because those // are the starting points when copying a word at the end. length := sub(length, 32) - let send := add(source, length) - let dend := add(dest, length) + let sEnd := add(source, length) + let dEnd := add(dest, length) // Remember the first 32 bytes of source // This needs to be done here and not after the loop @@ -125,10 +125,10 @@ contract LibMem let first := mload(source) // Copy whole words back to front - for {let i := 0} lt(i, nwords) {i := add(i, 1)} { - mstore(dend, mload(send)) - send := sub(send, 32) - dend := sub(dend, 32) + for {let i := 0} lt(i, nWords) {i := add(i, 1)} { + mstore(dEnd, mload(sEnd)) + sEnd := sub(sEnd, 32) + dEnd := sub(dEnd, 32) } // Write the first 32 bytes diff --git a/packages/contracts/test/libraries/lib_mem.ts b/packages/contracts/test/libraries/lib_mem.ts index efe719255..6291d3d08 100644 --- a/packages/contracts/test/libraries/lib_mem.ts +++ b/packages/contracts/test/libraries/lib_mem.ts @@ -27,7 +27,7 @@ describe('LibMem', () => { testLibMem = await TestLibMemContract.deployFrom0xArtifactAsync(artifacts.TestLibMem, provider, txDefaults); }); - describe('memcpy', () => { + describe('memCopy', () => { // Create memory 0x000102...FF const memSize = 256; const memory = new Uint8Array(memSize).map((_, i) => i); -- cgit v1.2.3