mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-20 19:42:04 +08:00
feat(core): improve priority queue performance (#11559)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { BinarySearchTree } from '@datastructures-js/binary-search-tree';
|
||||
import { BinarySearchTree } from './binary-search-tree';
|
||||
|
||||
export class PriorityQueue {
|
||||
tree = new BinarySearchTree<{ id: string; priority: number }>((a, b) => {
|
||||
@@ -39,8 +39,8 @@ export class PriorityQueue {
|
||||
return id;
|
||||
}
|
||||
|
||||
remove(id: string, priority?: number) {
|
||||
priority ??= this.priorityMap.get(id);
|
||||
remove(id: string) {
|
||||
const priority = this.priorityMap.get(id);
|
||||
if (priority === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user