reuse item position references in Y.Text

This commit is contained in:
Kevin Jahns
2020-06-05 00:27:36 +02:00
parent a5a48d07f6
commit 0a0098fdfb
3 changed files with 53 additions and 56 deletions

View File

@@ -438,7 +438,8 @@ export class Item extends AbstractStruct {
* Computes the last content address of this Item.
*/
get lastId () {
return createID(this.id.client, this.id.clock + this.length - 1)
// allocating ids is pretty costly because of the amount of ids created, so we try to reuse whenever possible
return this.length === 1 ? this.id : createID(this.id.client, this.id.clock + this.length - 1)
}
/**