Skip to content

Commit 41391d8

Browse files
quark-zjufacebook-github-bot
authored andcommitted
Move linelog construction logic to assignment
Summary: This simplified the logic a bit. Reviewed By: muirdm Differential Revision: D43810768 fbshipit-source-id: 4911c7543e07f9779f65cd3c4179ec2760488cee
1 parent f0e4636 commit 41391d8

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

addons/isl/src/linelog.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,42 +149,36 @@ interface FlattenLine {
149149
*/
150150
class LineLog {
151151
/** Core state: instructions. The array index type is `Pc`. */
152-
private code: Inst[];
152+
private code: Inst[] = [{op: Op.END}];
153153

154154
/**
155155
* Rev dependencies.
156156
* For example, `{5: [3, 1]}` means rev 5 depends on rev 3 and rev 1.
157157
* This is only updated when `trackDeps` is `true` during construction.
158158
*/
159-
readonly revDepMap: Map<Rev, Set<Rev>>;
159+
readonly revDepMap: Map<Rev, Set<Rev>> = new Map<Rev, Set<Rev>>();
160160

161161
/** If `true`, update `revDepMap` on change. */
162-
private trackDeps: boolean;
162+
private trackDeps = false;
163163

164164
/** Maximum rev tracked. */
165-
maxRev: Rev;
165+
maxRev: Rev = 0;
166166

167167
/** Cache key for `checkOut`. */
168-
private lastCheckoutKey: string;
168+
private lastCheckoutKey = '';
169169

170170
/** Result of a `checkOut`. */
171-
lines: LineInfo[];
171+
lines: LineInfo[] = [];
172172

173173
/** Content of lines joined. */
174-
content: string;
174+
content = '';
175175

176176
/**
177177
* Create a `LineLog` with empty content.
178178
* If `trackDeps` is `true`, rev dependencies are updated and
179179
* stored in `revDepMap`.
180180
*/
181181
constructor({trackDeps}: {trackDeps: boolean} = {trackDeps: false}) {
182-
this.code = [{op: Op.END}];
183-
this.revDepMap = new Map<Rev, Set<Rev>>();
184-
this.maxRev = 0;
185-
this.lastCheckoutKey = '';
186-
this.lines = [];
187-
this.content = '';
188182
this.trackDeps = trackDeps;
189183
this.checkOut(0);
190184
}

0 commit comments

Comments
 (0)