Partial Revert "Use equals helper function instead of re-implementing it so many places"

This reverts commit 40e0f496.
上级 61938981
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import { OperatingSystem } from 'vs/base/common/platform'; import { OperatingSystem } from 'vs/base/common/platform';
import { illegalArgument } from 'vs/base/common/errors'; import { illegalArgument } from 'vs/base/common/errors';
import { equals } from 'vs/base/common/arrays';
/** /**
* Virtual Key Codes, the value does not hold any inherent meaning. * Virtual Key Codes, the value does not hold any inherent meaning.
...@@ -526,7 +525,15 @@ export class ChordKeybinding { ...@@ -526,7 +525,15 @@ export class ChordKeybinding {
if (other === null) { if (other === null) {
return false; return false;
} }
return equals(this.parts, other.parts, (a, b) => a.equals(b)); if (this.parts.length !== other.parts.length) {
return false;
}
for (let i = 0; i < this.parts.length; i++) {
if (!this.parts[i].equals(other.parts[i])) {
return false;
}
}
return true;
} }
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import { IPosition, Position } from 'vs/editor/common/core/position'; import { IPosition, Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range'; import { Range } from 'vs/editor/common/core/range';
import { equals } from 'vs/base/common/arrays';
/** /**
* A selection in the editor. * A selection in the editor.
...@@ -172,7 +171,15 @@ export class Selection extends Range { ...@@ -172,7 +171,15 @@ export class Selection extends Range {
if (!a && !b) { if (!a && !b) {
return true; return true;
} }
return equals(a, b, this.selectionsEqual); if (a.length !== b.length) {
return false;
}
for (let i = 0, len = a.length; i < len; i++) {
if (!this.selectionsEqual(a[i], b[i])) {
return false;
}
}
return true;
} }
/** /**
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import * as strings from 'vs/base/common/strings'; import * as strings from 'vs/base/common/strings';
import { Constants } from 'vs/base/common/uint'; import { Constants } from 'vs/base/common/uint';
import { InlineDecoration, InlineDecorationType } from 'vs/editor/common/viewModel/viewModel'; import { InlineDecoration, InlineDecorationType } from 'vs/editor/common/viewModel/viewModel';
import { equals } from 'vs/base/common/arrays';
export class LineDecoration { export class LineDecoration {
_lineDecorationBrand: void; _lineDecorationBrand: void;
...@@ -28,8 +27,18 @@ export class LineDecoration { ...@@ -28,8 +27,18 @@ export class LineDecoration {
); );
} }
public static equalsArr(a: readonly LineDecoration[], b: readonly LineDecoration[]): boolean { public static equalsArr(a: LineDecoration[], b: LineDecoration[]): boolean {
return equals(a, b, LineDecoration._equals); let aLen = a.length;
let bLen = b.length;
if (aLen !== bLen) {
return false;
}
for (let i = 0; i < aLen; i++) {
if (!LineDecoration._equals(a[i], b[i])) {
return false;
}
}
return true;
} }
public static filter(lineDecorations: InlineDecoration[], lineNumber: number, minLineColumn: number, maxLineColumn: number): LineDecoration[] { public static filter(lineDecorations: InlineDecoration[], lineNumber: number, minLineColumn: number, maxLineColumn: number): LineDecoration[] {
......
...@@ -9,7 +9,6 @@ import { IViewLineTokens } from 'vs/editor/common/core/lineTokens'; ...@@ -9,7 +9,6 @@ import { IViewLineTokens } from 'vs/editor/common/core/lineTokens';
import { IStringBuilder, createStringBuilder } from 'vs/editor/common/core/stringBuilder'; import { IStringBuilder, createStringBuilder } from 'vs/editor/common/core/stringBuilder';
import { LineDecoration, LineDecorationsNormalizer } from 'vs/editor/common/viewLayout/lineDecorations'; import { LineDecoration, LineDecorationsNormalizer } from 'vs/editor/common/viewLayout/lineDecorations';
import { InlineDecorationType } from 'vs/editor/common/viewModel/viewModel'; import { InlineDecorationType } from 'vs/editor/common/viewModel/viewModel';
import { equals } from 'vs/base/common/arrays';
export const enum RenderWhitespace { export const enum RenderWhitespace {
None = 0, None = 0,
...@@ -132,7 +131,17 @@ export class RenderLineInput { ...@@ -132,7 +131,17 @@ export class RenderLineInput {
return false; return false;
} }
return equals(this.selectionsOnLine, otherSelections, (a, b) => a.equals(b)); if (otherSelections.length !== this.selectionsOnLine.length) {
return false;
}
for (let i = 0; i < this.selectionsOnLine.length; i++) {
if (!this.selectionsOnLine[i].equals(otherSelections[i])) {
return false;
}
}
return true;
} }
public equals(other: RenderLineInput): boolean { public equals(other: RenderLineInput): boolean {
......
...@@ -12,7 +12,6 @@ import { Selection } from 'vs/editor/common/core/selection'; ...@@ -12,7 +12,6 @@ import { Selection } from 'vs/editor/common/core/selection';
import { IEditorContribution, ScrollType } from 'vs/editor/common/editorCommon'; import { IEditorContribution, ScrollType } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { equals } from 'vs/base/common/arrays';
class CursorState { class CursorState {
readonly selections: readonly Selection[]; readonly selections: readonly Selection[];
...@@ -22,7 +21,17 @@ class CursorState { ...@@ -22,7 +21,17 @@ class CursorState {
} }
public equals(other: CursorState): boolean { public equals(other: CursorState): boolean {
return equals(this.selections, other.selections, (a, b) => a.equalsSelection(b)); const thisLen = this.selections.length;
const otherLen = other.selections.length;
if (thisLen !== otherLen) {
return false;
}
for (let i = 0; i < thisLen; i++) {
if (!this.selections[i].equalsSelection(other.selections[i])) {
return false;
}
}
return true;
} }
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import { IViewLineTokens } from 'vs/editor/common/core/lineTokens'; import { IViewLineTokens } from 'vs/editor/common/core/lineTokens';
import { ColorId, TokenMetadata } from 'vs/editor/common/modes'; import { ColorId, TokenMetadata } from 'vs/editor/common/modes';
import { equals } from 'vs/base/common/arrays';
/** /**
* A token on a line. * A token on a line.
...@@ -43,8 +42,18 @@ export class ViewLineToken { ...@@ -43,8 +42,18 @@ export class ViewLineToken {
); );
} }
public static equalsArr(a: readonly ViewLineToken[], b: readonly ViewLineToken[]): boolean { public static equalsArr(a: ViewLineToken[], b: ViewLineToken[]): boolean {
return equals(a, b, this._equals); const aLen = a.length;
const bLen = b.length;
if (aLen !== bLen) {
return false;
}
for (let i = 0; i < aLen; i++) {
if (!this._equals(a[i], b[i])) {
return false;
}
}
return true;
} }
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
import { isFalsyOrWhitespace } from 'vs/base/common/strings'; import { isFalsyOrWhitespace } from 'vs/base/common/strings';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { equals } from 'vs/base/common/arrays';
export const enum ContextKeyExprType { export const enum ContextKeyExprType {
Defined = 1, Defined = 1,
...@@ -575,7 +574,15 @@ export class ContextKeyAndExpr implements ContextKeyExpr { ...@@ -575,7 +574,15 @@ export class ContextKeyAndExpr implements ContextKeyExpr {
public equals(other: ContextKeyExpr): boolean { public equals(other: ContextKeyExpr): boolean {
if (other instanceof ContextKeyAndExpr) { if (other instanceof ContextKeyAndExpr) {
return equals(this.expr, other.expr, (a, b) => a.equals(b)); if (this.expr.length !== other.expr.length) {
return false;
}
for (let i = 0, len = this.expr.length; i < len; i++) {
if (!this.expr[i].equals(other.expr[i])) {
return false;
}
}
return true;
} }
return false; return false;
} }
...@@ -667,7 +674,15 @@ export class ContextKeyOrExpr implements ContextKeyExpr { ...@@ -667,7 +674,15 @@ export class ContextKeyOrExpr implements ContextKeyExpr {
public equals(other: ContextKeyExpr): boolean { public equals(other: ContextKeyExpr): boolean {
if (other instanceof ContextKeyOrExpr) { if (other instanceof ContextKeyOrExpr) {
return equals(this.expr, other.expr, (a, b) => a.equals(b)); if (this.expr.length !== other.expr.length) {
return false;
}
for (let i = 0, len = this.expr.length; i < len; i++) {
if (!this.expr[i].equals(other.expr[i])) {
return false;
}
}
return true;
} }
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册