Skip to content

Commit

Permalink
[fix] current uid is a stack
Browse files Browse the repository at this point in the history
This fixes #10
  • Loading branch information
AndreasMadsen committed Dec 5, 2016
1 parent 4f94d09 commit a88b889
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 145 deletions.
9 changes: 5 additions & 4 deletions dprof.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@ const root = new Node(
root.rootIntialize();

const nodes = new Map();
let currState = root;
const stateStack = [root];

function asyncInit(uid, handle, provider, parentUid) {
// get parent state
const state = (parentUid === null ? currState : nodes.get(parentUid));
const topState = stateStack[stateStack.length - 1];
const state = (parentUid === null ? topState : nodes.get(parentUid));

// add new state node
nodes.set(uid, state.add(uid, handle));
Expand All @@ -153,14 +154,14 @@ function asyncBefore(uid) {
const state = nodes.get(uid);

state.before();
currState = state;
stateStack.push(state);
}

function asyncAfter(uid) {
const state = nodes.get(uid);

state.after();
currState = root;
stateStack.pop();
}

function asyncDestroy(uid) {
Expand Down
Loading

0 comments on commit a88b889

Please sign in to comment.