Comparing version 0.4.5 to 0.4.6
@@ -1,2 +0,2 @@ | ||
S = typeof S === 'undefined' ? require('../dist/withsubclocks') : S; | ||
S = typeof S === 'undefined' ? require('..') : S; | ||
@@ -3,0 +3,0 @@ var now = typeof process === 'undefined' ? browserNow : nodeNow; |
@@ -125,3 +125,3 @@ // Public interface | ||
S.value = function value(current, eq) { | ||
var data = S.data(current), age = 0; | ||
var data = S.data(current), age = -1; | ||
return function value(update) { | ||
@@ -212,3 +212,2 @@ if (arguments.length === 0) { | ||
this.source1slot = 0; | ||
this.count = 0; | ||
this.sources = null; | ||
@@ -227,7 +226,4 @@ this.sourceslots = null; | ||
this.node1slot = 0; | ||
this.count = 0; | ||
this.nodes = null; | ||
this.nodeslots = null; | ||
this.freecount = 0; | ||
this.freeslots = null; | ||
} | ||
@@ -266,3 +262,3 @@ return Log; | ||
function logRead(from, to) { | ||
var fromslot, toslot = to.source1 === null ? -1 : to.count++; | ||
var fromslot, toslot = to.source1 === null ? -1 : to.sources === null ? 0 : to.sources.length; | ||
if (from.node1 === null) { | ||
@@ -276,9 +272,8 @@ from.node1 = to; | ||
from.nodeslots = [toslot]; | ||
from.count = 1; | ||
fromslot = 0; | ||
} | ||
else { | ||
fromslot = from.freecount !== 0 ? from.freeslots[--from.freecount] : from.count++, | ||
from.nodes[fromslot] = to; | ||
from.nodeslots[fromslot] = toslot; | ||
fromslot = from.nodes.length, | ||
from.nodes.push(to); | ||
from.nodeslots.push(toslot); | ||
} | ||
@@ -292,7 +287,6 @@ if (to.source1 === null) { | ||
to.sourceslots = [fromslot]; | ||
to.count = 1; | ||
} | ||
else { | ||
to.sources[toslot] = from; | ||
to.sourceslots[toslot] = fromslot; | ||
to.sources.push(from); | ||
to.sourceslots.push(fromslot); | ||
} | ||
@@ -363,31 +357,11 @@ } | ||
function markComputationsStale(log) { | ||
var node1 = log.node1, nodes = log.nodes, nodeslots = log.nodeslots, dead = 0, slot, nodeslot, node; | ||
var node1 = log.node1, nodes = log.nodes; | ||
// mark all downstream nodes stale which haven't been already | ||
if (node1 !== null) | ||
markNodeStale(node1); | ||
for (var i = 0; i < log.count; i++) { | ||
// compact log.nodes as we iterate through it | ||
node = nodes[i]; | ||
if (node) { | ||
markNodeStale(node); | ||
if (dead) { | ||
slot = i - dead; | ||
nodeslot = nodeslots[i]; | ||
nodes[i] = null; | ||
nodes[slot] = node; | ||
nodeslots[slot] = nodeslot; | ||
if (nodeslot === -1) { | ||
node.source1slot = slot; | ||
} | ||
else { | ||
node.sourceslots[nodeslot] = slot; | ||
} | ||
} | ||
if (nodes !== null) { | ||
for (var i = 0, len = nodes.length; i < len; i++) { | ||
markNodeStale(nodes[i]); | ||
} | ||
else { | ||
dead++; | ||
} | ||
} | ||
log.count -= dead; | ||
log.freecount = 0; | ||
} | ||
@@ -428,3 +402,3 @@ function markNodeStale(node) { | ||
function cleanup(node, final) { | ||
var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, i; | ||
var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, i, len; | ||
if (cleanups !== null) { | ||
@@ -446,9 +420,10 @@ for (i = 0; i < cleanups.length; i++) { | ||
} | ||
for (i = 0; i < node.count; i++) { | ||
cleanupSource(sources[i], sourceslots[i]); | ||
sources[i] = null; | ||
if (sources !== null) { | ||
for (i = 0, len = sources.length; i < len; i++) { | ||
cleanupSource(sources.pop(), sourceslots.pop()); | ||
} | ||
} | ||
node.count = 0; | ||
} | ||
function cleanupSource(source, slot) { | ||
var nodes = source.nodes, nodeslots = source.nodeslots, last, lastslot; | ||
if (slot === -1) { | ||
@@ -458,13 +433,14 @@ source.node1 = null; | ||
else { | ||
source.nodes[slot] = null; | ||
if (slot === source.count - 1) { | ||
source.count--; | ||
last = nodes.pop(); | ||
lastslot = nodeslots.pop(); | ||
if (slot !== nodes.length) { | ||
nodes[slot] = last; | ||
nodeslots[slot] = lastslot; | ||
if (lastslot === -1) { | ||
last.source1slot = slot; | ||
} | ||
else { | ||
last.sourceslots[lastslot] = slot; | ||
} | ||
} | ||
else if (source.freeslots === null) { | ||
source.freeslots = [slot]; | ||
source.freecount = 1; | ||
} | ||
else { | ||
source.freeslots[source.freecount++] = slot; | ||
} | ||
} | ||
@@ -471,0 +447,0 @@ } |
@@ -182,3 +182,3 @@ // Public interface | ||
S.value = function value(current, eq) { | ||
var data = S.data(current), clock = RunningClock || RootClock, age = 0; | ||
var data = S.data(current), clock = RunningClock || RootClock, age = -1; | ||
return function value(update) { | ||
@@ -309,3 +309,2 @@ if (arguments.length === 0) { | ||
this.source1slot = 0; | ||
this.count = 0; | ||
this.sources = null; | ||
@@ -325,7 +324,4 @@ this.sourceslots = null; | ||
this.node1slot = 0; | ||
this.count = 0; | ||
this.nodes = null; | ||
this.nodeslots = null; | ||
this.freecount = 0; | ||
this.freeslots = null; | ||
} | ||
@@ -384,3 +380,3 @@ return Log; | ||
function logRead(from, to) { | ||
var fromslot, toslot = to.source1 === null ? -1 : to.count++; | ||
var fromslot, toslot = to.source1 === null ? -1 : to.sources === null ? 0 : to.sources.length; | ||
if (from.node1 === null) { | ||
@@ -394,9 +390,8 @@ from.node1 = to; | ||
from.nodeslots = [toslot]; | ||
from.count = 1; | ||
fromslot = 0; | ||
} | ||
else { | ||
fromslot = from.freecount !== 0 ? from.freeslots[--from.freecount] : from.count++, | ||
from.nodes[fromslot] = to; | ||
from.nodeslots[fromslot] = toslot; | ||
fromslot = from.nodes.length; | ||
from.nodes.push(to); | ||
from.nodeslots.push(toslot); | ||
} | ||
@@ -410,7 +405,6 @@ if (to.source1 === null) { | ||
to.sourceslots = [fromslot]; | ||
to.count = 1; | ||
} | ||
else { | ||
to.sources[toslot] = from; | ||
to.sourceslots[toslot] = fromslot; | ||
to.sources.push(from); | ||
to.sourceslots.push(fromslot); | ||
} | ||
@@ -513,31 +507,11 @@ } | ||
function markComputationsStale(log) { | ||
var node1 = log.node1, nodes = log.nodes, nodeslots = log.nodeslots, dead = 0, slot, nodeslot, node; | ||
var node1 = log.node1, nodes = log.nodes; | ||
// mark all downstream nodes stale which haven't been already | ||
if (node1 !== null) | ||
markNodeStale(node1); | ||
for (var i = 0; i < log.count; i++) { | ||
// compact log.nodes as we iterate through it | ||
node = nodes[i]; | ||
if (node) { | ||
markNodeStale(node); | ||
if (dead) { | ||
slot = i - dead; | ||
nodeslot = nodeslots[i]; | ||
nodes[i] = null; | ||
nodes[slot] = node; | ||
nodeslots[slot] = nodeslot; | ||
if (nodeslot === -1) { | ||
node.source1slot = slot; | ||
} | ||
else { | ||
node.sourceslots[nodeslot] = slot; | ||
} | ||
} | ||
if (nodes !== null) { | ||
for (var i = 0, len = nodes.length; i < len; i++) { | ||
markNodeStale(nodes[i]); | ||
} | ||
else { | ||
dead++; | ||
} | ||
} | ||
log.count -= dead; | ||
log.freecount = 0; | ||
} | ||
@@ -618,3 +592,3 @@ function markNodeStale(node) { | ||
function cleanup(node, final) { | ||
var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, preclocks = node.preclocks, i; | ||
var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, preclocks = node.preclocks, i, len; | ||
if (cleanups !== null) { | ||
@@ -636,7 +610,7 @@ for (i = 0; i < cleanups.length; i++) { | ||
} | ||
for (i = 0; i < node.count; i++) { | ||
cleanupSource(sources[i], sourceslots[i]); | ||
sources[i] = null; | ||
if (sources !== null) { | ||
for (i = 0, len = sources.length; i < len; i++) { | ||
cleanupSource(sources.pop(), sourceslots.pop()); | ||
} | ||
} | ||
node.count = 0; | ||
if (preclocks !== null) { | ||
@@ -657,2 +631,3 @@ for (i = 0; i < preclocks.count; i++) { | ||
function cleanupSource(source, slot) { | ||
var nodes = source.nodes, nodeslots = source.nodeslots, last, lastslot; | ||
if (slot === -1) { | ||
@@ -662,13 +637,14 @@ source.node1 = null; | ||
else { | ||
source.nodes[slot] = null; | ||
if (slot === source.count - 1) { | ||
source.count--; | ||
last = nodes.pop(); | ||
lastslot = nodeslots.pop(); | ||
if (slot !== nodes.length) { | ||
nodes[slot] = last; | ||
nodeslots[slot] = lastslot; | ||
if (lastslot === -1) { | ||
last.source1slot = slot; | ||
} | ||
else { | ||
last.sourceslots[lastslot] = slot; | ||
} | ||
} | ||
else if (source.freeslots === null) { | ||
source.freeslots = [slot]; | ||
source.freecount = 1; | ||
} | ||
else { | ||
source.freeslots[source.freecount++] = slot; | ||
} | ||
} | ||
@@ -675,0 +651,0 @@ } |
@@ -130,3 +130,3 @@ (function (global, factory) { | ||
S.value = function value(current, eq) { | ||
var data = S.data(current), age = 0; | ||
var data = S.data(current), age = -1; | ||
return function value(update) { | ||
@@ -217,3 +217,2 @@ if (arguments.length === 0) { | ||
this.source1slot = 0; | ||
this.count = 0; | ||
this.sources = null; | ||
@@ -232,7 +231,4 @@ this.sourceslots = null; | ||
this.node1slot = 0; | ||
this.count = 0; | ||
this.nodes = null; | ||
this.nodeslots = null; | ||
this.freecount = 0; | ||
this.freeslots = null; | ||
} | ||
@@ -275,3 +271,3 @@ return Log; | ||
function logRead(from, to) { | ||
var fromslot, toslot = to.source1 === null ? -1 : to.count++; | ||
var fromslot, toslot = to.source1 === null ? -1 : to.sources === null ? 0 : to.sources.length; | ||
if (from.node1 === null) { | ||
@@ -285,9 +281,8 @@ from.node1 = to; | ||
from.nodeslots = [toslot]; | ||
from.count = 1; | ||
fromslot = 0; | ||
} | ||
else { | ||
fromslot = from.freecount !== 0 ? from.freeslots[--from.freecount] : from.count++, | ||
from.nodes[fromslot] = to; | ||
from.nodeslots[fromslot] = toslot; | ||
fromslot = from.nodes.length, | ||
from.nodes.push(to); | ||
from.nodeslots.push(toslot); | ||
} | ||
@@ -301,7 +296,6 @@ if (to.source1 === null) { | ||
to.sourceslots = [fromslot]; | ||
to.count = 1; | ||
} | ||
else { | ||
to.sources[toslot] = from; | ||
to.sourceslots[toslot] = fromslot; | ||
to.sources.push(from); | ||
to.sourceslots.push(fromslot); | ||
} | ||
@@ -372,31 +366,11 @@ } | ||
function markComputationsStale(log) { | ||
var node1 = log.node1, nodes = log.nodes, nodeslots = log.nodeslots, dead = 0, slot, nodeslot, node; | ||
var node1 = log.node1, nodes = log.nodes; | ||
// mark all downstream nodes stale which haven't been already | ||
if (node1 !== null) | ||
markNodeStale(node1); | ||
for (var i = 0; i < log.count; i++) { | ||
// compact log.nodes as we iterate through it | ||
node = nodes[i]; | ||
if (node) { | ||
markNodeStale(node); | ||
if (dead) { | ||
slot = i - dead; | ||
nodeslot = nodeslots[i]; | ||
nodes[i] = null; | ||
nodes[slot] = node; | ||
nodeslots[slot] = nodeslot; | ||
if (nodeslot === -1) { | ||
node.source1slot = slot; | ||
} | ||
else { | ||
node.sourceslots[nodeslot] = slot; | ||
} | ||
} | ||
if (nodes !== null) { | ||
for (var i = 0, len = nodes.length; i < len; i++) { | ||
markNodeStale(nodes[i]); | ||
} | ||
else { | ||
dead++; | ||
} | ||
} | ||
log.count -= dead; | ||
log.freecount = 0; | ||
} | ||
@@ -437,3 +411,3 @@ function markNodeStale(node) { | ||
function cleanup(node, final) { | ||
var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, i; | ||
var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, i, len; | ||
if (cleanups !== null) { | ||
@@ -455,9 +429,10 @@ for (i = 0; i < cleanups.length; i++) { | ||
} | ||
for (i = 0; i < node.count; i++) { | ||
cleanupSource(sources[i], sourceslots[i]); | ||
sources[i] = null; | ||
if (sources !== null) { | ||
for (i = 0, len = sources.length; i < len; i++) { | ||
cleanupSource(sources.pop(), sourceslots.pop()); | ||
} | ||
} | ||
node.count = 0; | ||
} | ||
function cleanupSource(source, slot) { | ||
var nodes = source.nodes, nodeslots = source.nodeslots, last, lastslot; | ||
if (slot === -1) { | ||
@@ -467,13 +442,14 @@ source.node1 = null; | ||
else { | ||
source.nodes[slot] = null; | ||
if (slot === source.count - 1) { | ||
source.count--; | ||
last = nodes.pop(); | ||
lastslot = nodeslots.pop(); | ||
if (slot !== nodes.length) { | ||
nodes[slot] = last; | ||
nodeslots[slot] = lastslot; | ||
if (lastslot === -1) { | ||
last.source1slot = slot; | ||
} | ||
else { | ||
last.sourceslots[lastslot] = slot; | ||
} | ||
} | ||
else if (source.freeslots === null) { | ||
source.freeslots = [slot]; | ||
source.freecount = 1; | ||
} | ||
else { | ||
source.freeslots[source.freecount++] = slot; | ||
} | ||
} | ||
@@ -480,0 +456,0 @@ } |
@@ -187,3 +187,3 @@ (function (global, factory) { | ||
S.value = function value(current, eq) { | ||
var data = S.data(current), clock = RunningClock || RootClock, age = 0; | ||
var data = S.data(current), clock = RunningClock || RootClock, age = -1; | ||
return function value(update) { | ||
@@ -314,3 +314,2 @@ if (arguments.length === 0) { | ||
this.source1slot = 0; | ||
this.count = 0; | ||
this.sources = null; | ||
@@ -330,7 +329,4 @@ this.sourceslots = null; | ||
this.node1slot = 0; | ||
this.count = 0; | ||
this.nodes = null; | ||
this.nodeslots = null; | ||
this.freecount = 0; | ||
this.freeslots = null; | ||
} | ||
@@ -393,3 +389,3 @@ return Log; | ||
function logRead(from, to) { | ||
var fromslot, toslot = to.source1 === null ? -1 : to.count++; | ||
var fromslot, toslot = to.source1 === null ? -1 : to.sources === null ? 0 : to.sources.length; | ||
if (from.node1 === null) { | ||
@@ -403,9 +399,8 @@ from.node1 = to; | ||
from.nodeslots = [toslot]; | ||
from.count = 1; | ||
fromslot = 0; | ||
} | ||
else { | ||
fromslot = from.freecount !== 0 ? from.freeslots[--from.freecount] : from.count++, | ||
from.nodes[fromslot] = to; | ||
from.nodeslots[fromslot] = toslot; | ||
fromslot = from.nodes.length; | ||
from.nodes.push(to); | ||
from.nodeslots.push(toslot); | ||
} | ||
@@ -419,7 +414,6 @@ if (to.source1 === null) { | ||
to.sourceslots = [fromslot]; | ||
to.count = 1; | ||
} | ||
else { | ||
to.sources[toslot] = from; | ||
to.sourceslots[toslot] = fromslot; | ||
to.sources.push(from); | ||
to.sourceslots.push(fromslot); | ||
} | ||
@@ -522,31 +516,11 @@ } | ||
function markComputationsStale(log) { | ||
var node1 = log.node1, nodes = log.nodes, nodeslots = log.nodeslots, dead = 0, slot, nodeslot, node; | ||
var node1 = log.node1, nodes = log.nodes; | ||
// mark all downstream nodes stale which haven't been already | ||
if (node1 !== null) | ||
markNodeStale(node1); | ||
for (var i = 0; i < log.count; i++) { | ||
// compact log.nodes as we iterate through it | ||
node = nodes[i]; | ||
if (node) { | ||
markNodeStale(node); | ||
if (dead) { | ||
slot = i - dead; | ||
nodeslot = nodeslots[i]; | ||
nodes[i] = null; | ||
nodes[slot] = node; | ||
nodeslots[slot] = nodeslot; | ||
if (nodeslot === -1) { | ||
node.source1slot = slot; | ||
} | ||
else { | ||
node.sourceslots[nodeslot] = slot; | ||
} | ||
} | ||
if (nodes !== null) { | ||
for (var i = 0, len = nodes.length; i < len; i++) { | ||
markNodeStale(nodes[i]); | ||
} | ||
else { | ||
dead++; | ||
} | ||
} | ||
log.count -= dead; | ||
log.freecount = 0; | ||
} | ||
@@ -627,3 +601,3 @@ function markNodeStale(node) { | ||
function cleanup(node, final) { | ||
var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, preclocks = node.preclocks, i; | ||
var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, preclocks = node.preclocks, i, len; | ||
if (cleanups !== null) { | ||
@@ -645,7 +619,7 @@ for (i = 0; i < cleanups.length; i++) { | ||
} | ||
for (i = 0; i < node.count; i++) { | ||
cleanupSource(sources[i], sourceslots[i]); | ||
sources[i] = null; | ||
if (sources !== null) { | ||
for (i = 0, len = sources.length; i < len; i++) { | ||
cleanupSource(sources.pop(), sourceslots.pop()); | ||
} | ||
} | ||
node.count = 0; | ||
if (preclocks !== null) { | ||
@@ -666,2 +640,3 @@ for (i = 0; i < preclocks.count; i++) { | ||
function cleanupSource(source, slot) { | ||
var nodes = source.nodes, nodeslots = source.nodeslots, last, lastslot; | ||
if (slot === -1) { | ||
@@ -671,13 +646,14 @@ source.node1 = null; | ||
else { | ||
source.nodes[slot] = null; | ||
if (slot === source.count - 1) { | ||
source.count--; | ||
last = nodes.pop(); | ||
lastslot = nodeslots.pop(); | ||
if (slot !== nodes.length) { | ||
nodes[slot] = last; | ||
nodeslots[slot] = lastslot; | ||
if (lastslot === -1) { | ||
last.source1slot = slot; | ||
} | ||
else { | ||
last.sourceslots[lastslot] = slot; | ||
} | ||
} | ||
else if (source.freeslots === null) { | ||
source.freeslots = [slot]; | ||
source.freecount = 1; | ||
} | ||
else { | ||
source.freeslots[source.freecount++] = slot; | ||
} | ||
} | ||
@@ -684,0 +660,0 @@ } |
{ | ||
"name": "s-js", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "S.js - simple, clean, fast reactive programming in Javascript", | ||
@@ -5,0 +5,0 @@ "main": "dist/S.js", |
88
src/S.ts
@@ -166,3 +166,3 @@ | ||
var data = S.data(current), | ||
age = 0; | ||
age = -1; | ||
return function value(update? : T) { | ||
@@ -255,3 +255,2 @@ if (arguments.length === 0) { | ||
source1slot = 0; | ||
count = 0; | ||
sources = null as null | Log[]; | ||
@@ -274,7 +273,4 @@ sourceslots = null as null | number[]; | ||
node1slot = 0; | ||
count = 0; | ||
nodes = null as null | (ComputationNode | null)[]; | ||
nodes = null as null | ComputationNode[]; | ||
nodeslots = null as null | number[]; | ||
freecount = 0; | ||
freeslots = null as null | number[]; | ||
} | ||
@@ -320,3 +316,3 @@ | ||
var fromslot : number, | ||
toslot = to.source1 === null ? -1 : to.count++; | ||
toslot = to.source1 === null ? -1 : to.sources === null ? 0 : to.sources.length; | ||
@@ -330,8 +326,7 @@ if (from.node1 === null) { | ||
from.nodeslots = [toslot]; | ||
from.count = 1; | ||
fromslot = 0; | ||
} else { | ||
fromslot = from.freecount !== 0 ? from.freeslots![--from.freecount] : from.count++, | ||
from.nodes[fromslot] = to; | ||
from.nodeslots![fromslot] = toslot; | ||
fromslot = from.nodes.length, | ||
from.nodes.push(to); | ||
from.nodeslots!.push(toslot); | ||
} | ||
@@ -345,6 +340,5 @@ | ||
to.sourceslots = [fromslot]; | ||
to.count = 1; | ||
} else { | ||
to.sources[toslot] = from; | ||
to.sourceslots![toslot] = fromslot; | ||
to.sources.push(from); | ||
to.sourceslots!.push(fromslot); | ||
} | ||
@@ -427,36 +421,11 @@ } | ||
var node1 = log.node1, | ||
nodes = log.nodes, | ||
nodeslots = log.nodeslots, | ||
dead = 0, | ||
slot : number, | ||
nodeslot : number, | ||
node : null | ComputationNode; | ||
nodes = log.nodes; | ||
// mark all downstream nodes stale which haven't been already | ||
if (node1 !== null) markNodeStale(node1); | ||
for (var i = 0; i < log.count; i++) { | ||
// compact log.nodes as we iterate through it | ||
node = nodes![i]; | ||
if (node) { | ||
markNodeStale(node); | ||
if (dead) { | ||
slot = i - dead; | ||
nodeslot = nodeslots![i]; | ||
nodes![i] = null; | ||
nodes![slot] = node; | ||
nodeslots![slot] = nodeslot; | ||
if (nodeslot === -1) { | ||
node.source1slot = slot; | ||
} else { | ||
node.sourceslots![nodeslot] = slot; | ||
} | ||
} | ||
} else { | ||
dead++; | ||
if (nodes !== null) { | ||
for (var i = 0, len = nodes.length; i < len; i++) { | ||
markNodeStale(nodes[i]); | ||
} | ||
} | ||
log.count -= dead; | ||
log.freecount = 0; | ||
} | ||
@@ -507,3 +476,4 @@ | ||
owned = node.owned, | ||
i : number; | ||
i : number, | ||
len : number; | ||
@@ -528,21 +498,27 @@ if (cleanups !== null) { | ||
} | ||
for (i = 0; i < node.count; i++) { | ||
cleanupSource(sources![i], sourceslots![i]); | ||
sources![i] = null!; | ||
if (sources !== null) { | ||
for (i = 0, len = sources.length; i < len; i++) { | ||
cleanupSource(sources.pop()!, sourceslots!.pop()!); | ||
} | ||
} | ||
node.count = 0; | ||
} | ||
function cleanupSource(source : Log, slot : number) { | ||
var nodes = source.nodes!, | ||
nodeslots = source.nodeslots!, | ||
last : ComputationNode, | ||
lastslot : number; | ||
if (slot === -1) { | ||
source.node1 = null; | ||
} else { | ||
source.nodes![slot] = null; | ||
if (slot === source.count - 1) { | ||
source.count--; | ||
} else if (source.freeslots === null) { | ||
source.freeslots = [slot]; | ||
source.freecount = 1; | ||
} else { | ||
source.freeslots[source.freecount++] = slot; | ||
last = nodes.pop()!; | ||
lastslot = nodeslots.pop()!; | ||
if (slot !== nodes.length) { | ||
nodes[slot] = last; | ||
nodeslots[slot] = lastslot; | ||
if (lastslot === -1) { | ||
last.source1slot = slot; | ||
} else { | ||
last.sourceslots![lastslot] = slot; | ||
} | ||
} | ||
@@ -549,0 +525,0 @@ } |
@@ -229,3 +229,3 @@ | ||
clock = RunningClock || RootClock, | ||
age = 0; | ||
age = -1; | ||
return function value(update? : T) { | ||
@@ -367,3 +367,2 @@ if (arguments.length === 0) { | ||
source1slot = 0; | ||
count = 0; | ||
sources = null as null | Log[]; | ||
@@ -388,7 +387,4 @@ sourceslots = null as null | number[]; | ||
node1slot = 0; | ||
count = 0; | ||
nodes = null as null | (ComputationNode | null)[]; | ||
nodes = null as null | ComputationNode[]; | ||
nodeslots = null as null | number[]; | ||
freecount = 0; | ||
freeslots = null as null | number[]; | ||
} | ||
@@ -450,3 +446,3 @@ | ||
var fromslot : number, | ||
toslot = to.source1 === null ? -1 : to.count++; | ||
toslot = to.source1 === null ? -1 : to.sources === null ? 0 : to.sources.length; | ||
@@ -460,8 +456,7 @@ if (from.node1 === null) { | ||
from.nodeslots = [toslot]; | ||
from.count = 1; | ||
fromslot = 0; | ||
} else { | ||
fromslot = from.freecount !== 0 ? from.freeslots![--from.freecount] : from.count++, | ||
from.nodes[fromslot] = to; | ||
from.nodeslots![fromslot] = toslot; | ||
fromslot = from.nodes.length; | ||
from.nodes.push(to); | ||
from.nodeslots!.push(toslot); | ||
} | ||
@@ -475,6 +470,5 @@ | ||
to.sourceslots = [fromslot]; | ||
to.count = 1; | ||
} else { | ||
to.sources[toslot] = from; | ||
to.sourceslots![toslot] = fromslot; | ||
to.sources.push(from); | ||
to.sourceslots!.push(fromslot); | ||
} | ||
@@ -590,36 +584,11 @@ } | ||
var node1 = log.node1, | ||
nodes = log.nodes, | ||
nodeslots = log.nodeslots, | ||
dead = 0, | ||
slot : number, | ||
nodeslot : number, | ||
node : null | ComputationNode; | ||
nodes = log.nodes; | ||
// mark all downstream nodes stale which haven't been already | ||
if (node1 !== null) markNodeStale(node1); | ||
for (var i = 0; i < log.count; i++) { | ||
// compact log.nodes as we iterate through it | ||
node = nodes![i]; | ||
if (node) { | ||
markNodeStale(node); | ||
if (dead) { | ||
slot = i - dead; | ||
nodeslot = nodeslots![i]; | ||
nodes![i] = null; | ||
nodes![slot] = node; | ||
nodeslots![slot] = nodeslot; | ||
if (nodeslot === -1) { | ||
node.source1slot = slot; | ||
} else { | ||
node.sourceslots![nodeslot] = slot; | ||
} | ||
} | ||
} else { | ||
dead++; | ||
if (nodes !== null) { | ||
for (var i = 0, len = nodes.length; i < len; i++) { | ||
markNodeStale(nodes[i]); | ||
} | ||
} | ||
log.count -= dead; | ||
log.freecount = 0; | ||
} | ||
@@ -712,3 +681,4 @@ | ||
preclocks = node.preclocks, | ||
i : number; | ||
i : number, | ||
len : number; | ||
@@ -733,7 +703,7 @@ if (cleanups !== null) { | ||
} | ||
for (i = 0; i < node.count; i++) { | ||
cleanupSource(sources![i], sourceslots![i]); | ||
sources![i] = null!; | ||
if (sources !== null) { | ||
for (i = 0, len = sources.length; i < len; i++) { | ||
cleanupSource(sources.pop()!, sourceslots!.pop()!); | ||
} | ||
} | ||
node.count = 0; | ||
@@ -758,13 +728,19 @@ if (preclocks !== null) { | ||
function cleanupSource(source : Log, slot : number) { | ||
var nodes = source.nodes!, | ||
nodeslots = source.nodeslots!, | ||
last : ComputationNode, | ||
lastslot : number; | ||
if (slot === -1) { | ||
source.node1 = null; | ||
} else { | ||
source.nodes![slot] = null; | ||
if (slot === source.count - 1) { | ||
source.count--; | ||
} else if (source.freeslots === null) { | ||
source.freeslots = [slot]; | ||
source.freecount = 1; | ||
} else { | ||
source.freeslots[source.freecount++] = slot; | ||
last = nodes.pop()!; | ||
lastslot = nodeslots.pop()!; | ||
if (slot !== nodes.length) { | ||
nodes[slot] = last; | ||
nodeslots[slot] = lastslot; | ||
if (lastslot === -1) { | ||
last.source1slot = slot; | ||
} else { | ||
last.sourceslots![lastslot] = slot; | ||
} | ||
} | ||
@@ -771,0 +747,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41
175221
4658