more efficient length computing
This commit is contained in:
@@ -72,6 +72,10 @@ export class YArrayEvent extends YEvent {
|
||||
* A shared Array implementation.
|
||||
*/
|
||||
export class YArray extends Type {
|
||||
constructor () {
|
||||
super()
|
||||
this.length = 0
|
||||
}
|
||||
/**
|
||||
* Creates YArray Event and calls observers.
|
||||
*
|
||||
@@ -167,21 +171,6 @@ export class YArray extends Type {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the length of this YArray.
|
||||
*/
|
||||
get length () {
|
||||
let length = 0
|
||||
let n = this._start
|
||||
while (n !== null) {
|
||||
if (!n._deleted && n._countable) {
|
||||
length += n._length
|
||||
}
|
||||
n = n._right
|
||||
}
|
||||
return length
|
||||
}
|
||||
|
||||
[Symbol.iterator] () {
|
||||
return {
|
||||
next: function () {
|
||||
|
||||
Reference in New Issue
Block a user