mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
faster state
This commit is contained in:
parent
b085d7a197
commit
e0153db653
8
gun.js
8
gun.js
@ -542,13 +542,19 @@
|
||||
var Type = require('./type');
|
||||
var Node = require('./node');
|
||||
function State(){
|
||||
var t = time();
|
||||
var t;
|
||||
if(perf){
|
||||
t = start + perf.now();
|
||||
} else {
|
||||
t = time();
|
||||
}
|
||||
if(last < t){
|
||||
return N = 0, last = t;
|
||||
}
|
||||
return last = t + ((N += 1) / D);
|
||||
}
|
||||
var time = Type.time.is, last = -Infinity, N = 0, D = 1000; // WARNING! In the future, on machines that are D times faster than 2016AD machines, you will want to increase D by another several orders of magnitude so the processing speed never out paces the decimal resolution (increasing an integer effects the state accuracy).
|
||||
var perf = (typeof performance !== 'undefined')? (performance.timing && performance) : false, start = (perf && perf.timing && perf.timing.navigationStart) || (perf = false);
|
||||
State._ = '>';
|
||||
State.ify = function(n, f, s, v, soul){ // put a field's state on a node.
|
||||
if(!n || !n[N_]){ // reject if it is not node-like.
|
||||
|
2
gun.min.js
vendored
2
gun.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,9 +1,8 @@
|
||||
|
||||
var Gun = require('./root');
|
||||
Gun.chain.get = function(key, cb, as){
|
||||
//if(!as || !as.path){ var back = this._.root; } // TODO: CHANGING API! Remove this line!
|
||||
if(typeof key === 'string'){
|
||||
var gun, back = back || this, cat = back._;
|
||||
var gun, back = this, cat = back._;
|
||||
var next = cat.next || empty, tmp;
|
||||
if(!(gun = next[key])){
|
||||
gun = cache(key, back);
|
||||
|
@ -2,13 +2,19 @@
|
||||
var Type = require('./type');
|
||||
var Node = require('./node');
|
||||
function State(){
|
||||
var t = time();
|
||||
var t;
|
||||
if(perf){
|
||||
t = start + perf.now();
|
||||
} else {
|
||||
t = time();
|
||||
}
|
||||
if(last < t){
|
||||
return N = 0, last = t;
|
||||
}
|
||||
return last = t + ((N += 1) / D);
|
||||
}
|
||||
var time = Type.time.is, last = -Infinity, N = 0, D = 1000; // WARNING! In the future, on machines that are D times faster than 2016AD machines, you will want to increase D by another several orders of magnitude so the processing speed never out paces the decimal resolution (increasing an integer effects the state accuracy).
|
||||
var perf = (typeof performance !== 'undefined')? (performance.timing && performance) : false, start = (perf && perf.timing && perf.timing.navigationStart) || (perf = false);
|
||||
State._ = '>';
|
||||
State.ify = function(n, f, s, v, soul){ // put a field's state on a node.
|
||||
if(!n || !n[N_]){ // reject if it is not node-like.
|
||||
|
Loading…
x
Reference in New Issue
Block a user