mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 01:37:20 +00:00
Partial Revert "Replacing more for loops with .every/.some or arrays.equals"
This reverts commit 2719c1ddc0
.
This commit is contained in:
parent
4f54f19553
commit
7462c67a68
3 changed files with 46 additions and 8 deletions
|
@ -21,10 +21,14 @@ import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
|||
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { equals } from 'vs/base/common/arrays';
|
||||
|
||||
function containsLineMappingChanged(events: readonly viewEvents.ViewEvent[]): boolean {
|
||||
return events.some(event => event.type === viewEvents.ViewEventType.ViewLineMappingChanged);
|
||||
function containsLineMappingChanged(events: viewEvents.ViewEvent[]): boolean {
|
||||
for (let i = 0, len = events.length; i < len; i++) {
|
||||
if (events[i].type === viewEvents.ViewEventType.ViewLineMappingChanged) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export class CursorStateChangedEvent {
|
||||
|
@ -69,7 +73,15 @@ export class CursorModelState {
|
|||
if (this.modelVersionId !== other.modelVersionId) {
|
||||
return false;
|
||||
}
|
||||
return equals(this.cursorState, other.cursorState, (a, b) => a.equals(b));
|
||||
if (this.cursorState.length !== other.cursorState.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0, len = this.cursorState.length; i < len; i++) {
|
||||
if (!this.cursorState[i].equals(other.cursorState[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -937,7 +949,12 @@ class CommandExecutor {
|
|||
}
|
||||
|
||||
private static _arrayIsEmpty(commands: (editorCommon.ICommand | null)[]): boolean {
|
||||
return commands.every(command => !command);
|
||||
for (let i = 0, len = commands.length; i < len; i++) {
|
||||
if (commands[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static _getEditOperations(ctx: IExecContext, commands: (editorCommon.ICommand | null)[]): ICommandsData {
|
||||
|
|
|
@ -21,7 +21,18 @@ import { IMonarchLanguage, IMonarchLanguageBracket } from 'vs/editor/standalone/
|
|||
*/
|
||||
|
||||
function isArrayOf(elemType: (x: any) => boolean, obj: any): boolean {
|
||||
return Array.isArray(obj) && obj.every(elemType);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
if (!(Array.isArray(obj))) {
|
||||
return false;
|
||||
}
|
||||
for (const el of obj) {
|
||||
if (!(elemType(el))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function bool(prop: any, defValue: boolean): boolean {
|
||||
|
|
|
@ -203,14 +203,24 @@ class SimpleContextKeyChangeEvent implements IContextKeyChangeEvent {
|
|||
class ArrayContextKeyChangeEvent implements IContextKeyChangeEvent {
|
||||
constructor(readonly keys: string[]) { }
|
||||
affectsSome(keys: IReadableSet<string>): boolean {
|
||||
return this.keys.some(key => keys.has(key));
|
||||
for (const key of this.keys) {
|
||||
if (keys.has(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class CompositeContextKeyChangeEvent implements IContextKeyChangeEvent {
|
||||
constructor(readonly events: IContextKeyChangeEvent[]) { }
|
||||
affectsSome(keys: IReadableSet<string>): boolean {
|
||||
return this.events.some(e => e.affectsSome(keys));
|
||||
for (const e of this.events) {
|
||||
if (e.affectsSome(keys)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue