Skip to content

Commit

Permalink
Code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey committed Dec 22, 2023
1 parent d3b0d9e commit e51ae7a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions vm-mock/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ export default function createMockedABI(
);
}

function concatenateArrays(oldValue, newValue) {

Check warning on line 220 in vm-mock/vm.js

View workflow job for this annotation

GitHub Actions / build

Missing JSDoc comment
const totalLength = oldValue.byteLength + newValue.byteLength;
return new Uint8Array(totalLength);
}

resetLedger();

const myImports = {
Expand Down Expand Up @@ -369,9 +374,7 @@ export default function createMockedABI(
}

const oldValue = addressStorage.get(key);
const concat = new Uint8Array(
oldValue.byteLength + newValue.byteLength,
);
const concat = concatenateArrays(oldValue, newValue);
concat.set(new Uint8Array(oldValue), 0);
concat.set(new Uint8Array(newValue), oldValue.byteLength);

Expand All @@ -394,9 +397,7 @@ export default function createMockedABI(
}

const oldValue = addressStorage.get(key);
const concat = new Uint8Array(
oldValue.byteLength + newValue.byteLength,
);
const concat = concatenateArrays(oldValue, newValue);
concat.set(new Uint8Array(oldValue), 0);
concat.set(new Uint8Array(newValue), oldValue.byteLength);

Expand Down

0 comments on commit e51ae7a

Please sign in to comment.