Skip to content

Commit

Permalink
Convert object to class for better compilation
Browse files Browse the repository at this point in the history
Under some closure flags the hostStack object was being split out into three unrelated functions. Converting it to a class makes the code more regular, and compile with more optimizations on.

There's almost definitely a way to express what we were doing with closure annotations, but this seems more robust to me.
  • Loading branch information
rictic authored Jun 27, 2018
1 parent 665901a commit b268117
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -2772,41 +2772,39 @@ export const PropertyEffects = dedupingMixin(superClass => {
*
* @private
*/
let hostStack = {

stack: [],
class HostStack {
constructor() {
this.stack = [];
}

/**
* @param {*} inst Instance to add to hostStack
* @return {void}
* @this {hostStack}
*/
registerHost(inst) {
if (this.stack.length) {
let host = this.stack[this.stack.length-1];
host._enqueueClient(inst);
}
},
}

/**
* @param {*} inst Instance to begin hosting
* @return {void}
* @this {hostStack}
*/
beginHosting(inst) {
this.stack.push(inst);
},
}

/**
* @param {*} inst Instance to end hosting
* @return {void}
* @this {hostStack}
*/
endHosting(inst) {
let stackLen = this.stack.length;
if (stackLen && this.stack[stackLen-1] == inst) {
this.stack.pop();
}
}

};
}
const hostStack = new HostStack();

0 comments on commit b268117

Please sign in to comment.