Skip to content

Commit

Permalink
fix: remove extra alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoon committed Jul 27, 2018
1 parent d130d19 commit bfd7dd7
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/actions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ export class Actions {
/**
* Every Vim action will be added here with the @RegisterAction decorator.
*/
public static allActions: { type: typeof BaseAction; action: BaseAction }[] = [];

public static actionMap = new Map<ModeName, { type: typeof BaseAction; action: BaseAction }[]>();
public static actionMap = new Map<ModeName, BaseAction[]>();
/**
* Gets the action that should be triggered given a key
* sequence.
Expand All @@ -199,13 +197,10 @@ export class Actions {
let isPotentialMatch = false;

var possibleActionsForMode = Actions.actionMap.get(vimState.currentMode) || [];
for (const possibleAction of possibleActionsForMode) {
const { type, action } = possibleAction!;

for (const action of possibleActionsForMode) {
if (action.doesActionApply(vimState, keysPressed)) {
const result = new type();
result.keysPressed = vimState.recordedState.actionKeys.slice(0);
return result;
action.keysPressed = vimState.recordedState.actionKeys.slice(0);
return action;
}

if (action.couldActionApply(vimState, keysPressed)) {
Expand All @@ -231,6 +226,6 @@ export function RegisterAction(action: typeof BaseAction): void {
continue;
}

actions.push({ type: action, action: actionInstance });
actions.push(actionInstance);
}
}

0 comments on commit bfd7dd7

Please sign in to comment.