Skip to content

Commit

Permalink
perf(events): moves out side-effect from LinkedItem constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
stalniy committed Sep 25, 2020
1 parent abaec1a commit 3657c7f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/casl-ability/src/PureAbility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class PureAbility<
const rules = this.rulesFor(...args);
const subject = args[1];

for (let i = 0; i < rules.length; i++) {
for (let i = 0, length = rules.length; i < length; i++) {
if (rules[i].matchesConditions(subject)) {
return rules[i];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/casl-ability/src/RuleIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class RuleIndex<A extends Abilities, Conditions> {
event: T,
handler: EventHandler<EventsMap<Public<this>>[T]>
): Unsubscribe {
const head = this._events.get(event) || null;
const head = this._events.has(event) ? this._events.get(event) : null;
const item = new LinkedItem(handler, head);
this._events.set(event, item);

Expand Down

0 comments on commit 3657c7f

Please sign in to comment.