From 885a74047052ddce9f03dd8e0478de9b51b84bd4 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Thu, 15 Jun 2023 13:09:30 +0200 Subject: [PATCH] heavily improve performance when there are many events --- src/utils/YEvent.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/YEvent.js b/src/utils/YEvent.js index ac877bc5..8aafd94f 100644 --- a/src/utils/YEvent.js +++ b/src/utils/YEvent.js @@ -44,6 +44,10 @@ export class YEvent { * @type {null | Array<{ insert?: string | Array | object | AbstractType, retain?: number, delete?: number, attributes?: Object }>} */ this._delta = null + /** + * @type {Array|null} + */ + this._path = null } /** @@ -60,8 +64,7 @@ export class YEvent { * type === event.target // => true */ get path () { - // @ts-ignore _item is defined because target is integrated - return getPathTo(this.currentTarget, this.target) + return this._path || (this._path = getPathTo(this.currentTarget, this.target)) } /**