Skip to content

Commit

Permalink
fast mergeArray function
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 24, 2020
1 parent 129959d commit 96f48a9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,9 @@ export function flagMessages(inputs: Array<Message>, cache: Map<string, Message>

return { oldKept: Array.from(oldKept.values()), oldRemoved: Array.from(oldRemoved), newAdded: Array.from(newAdded) }
}

// fast mergeArray function
// https://uilicious.com/blog/javascript-array-push-is-945x-faster-than-array-concat/
export function mergeArray(arr1: Array, arr2: Array) {
Array.prototype.push.apply(arr1, arr2)
}

0 comments on commit 96f48a9

Please sign in to comment.