mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Changeset: Use clear()
to initialize
This avoids some duplicate code and it helps ensure that `clear()` works properly.
This commit is contained in:
parent
8c01b66d40
commit
04ed432a01
1 changed files with 7 additions and 7 deletions
|
@ -323,6 +323,11 @@ class OpAssembler {
|
||||||
class MergingOpAssembler {
|
class MergingOpAssembler {
|
||||||
constructor() {
|
constructor() {
|
||||||
this._assem = new OpAssembler();
|
this._assem = new OpAssembler();
|
||||||
|
this.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this._assem.clear();
|
||||||
this._bufOp = new Op();
|
this._bufOp = new Op();
|
||||||
// If we get, for example, insertions [xxx\n,yyy], those don't merge, but if we get
|
// If we get, for example, insertions [xxx\n,yyy], those don't merge, but if we get
|
||||||
// [xxx\n,yyy,zzz\n], that merges to [xxx\nyyyzzz\n]. This variable stores the length of yyy and
|
// [xxx\n,yyy,zzz\n], that merges to [xxx\nyyyzzz\n]. This variable stores the length of yyy and
|
||||||
|
@ -330,11 +335,6 @@ class MergingOpAssembler {
|
||||||
this._bufOpAdditionalCharsAfterNewline = 0;
|
this._bufOpAdditionalCharsAfterNewline = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
|
||||||
this._assem.clear();
|
|
||||||
clearOp(this._bufOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
_flush(isEndDocument) {
|
_flush(isEndDocument) {
|
||||||
if (!this._bufOp.opcode) return;
|
if (!this._bufOp.opcode) return;
|
||||||
if (isEndDocument && this._bufOp.opcode === '=' && !this._bufOp.attribs) {
|
if (isEndDocument && this._bufOp.opcode === '=' && !this._bufOp.attribs) {
|
||||||
|
@ -431,8 +431,7 @@ class SmartOpAssembler {
|
||||||
this._plusAssem = new MergingOpAssembler();
|
this._plusAssem = new MergingOpAssembler();
|
||||||
this._keepAssem = new MergingOpAssembler();
|
this._keepAssem = new MergingOpAssembler();
|
||||||
this._assem = exports.stringAssembler();
|
this._assem = exports.stringAssembler();
|
||||||
this._lastOpcode = '';
|
this.clear();
|
||||||
this._lengthChange = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
@ -440,6 +439,7 @@ class SmartOpAssembler {
|
||||||
this._plusAssem.clear();
|
this._plusAssem.clear();
|
||||||
this._keepAssem.clear();
|
this._keepAssem.clear();
|
||||||
this._assem.clear();
|
this._assem.clear();
|
||||||
|
this._lastOpcode = '';
|
||||||
this._lengthChange = 0;
|
this._lengthChange = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue