Skip to content

Commit

Permalink
perf: optimised sorted events find when head is tail
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Jan 10, 2024
1 parent e1e1db6 commit 7b9975b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/crdt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ const findCommonString = (arrays) => {
* @param {API.EventLink<API.Operation>} tail
*/
const findSortedEvents = async (events, head, tail) => {
if (head.length === 1 && head[0].toString() === tail.toString()) {
return []
}

// get weighted events - heavier events happened first
/** @type {Map<string, { event: API.EventBlockView<API.Operation>, weight: number }>} */
const weights = new Map()
Expand Down

0 comments on commit 7b9975b

Please sign in to comment.