Skip to content

Commit

Permalink
v1.4.3-a
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayMakhonin committed Oct 12, 2020
1 parent 5b2491e commit 2a50690
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 182 deletions.
199 changes: 70 additions & 129 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1.4.0-a - 1.4.2-a / 2020-10-12
1.4.0-a - 1.4.3-a / 2020-10-12
===================

Added custom calc depend func args valueIds
Expand Down
36 changes: 19 additions & 17 deletions dist/js/main/common/rx/depend/core/CallState.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ function deleteValueState(valueId, value) {


var valueIdsBufferLength = 0;
var valueIdsBuffer = new Int32Array(100);
var valueIdsBuffer = [0];

function pushValueId(valueId) {
if (valueId === 0) {
Expand Down Expand Up @@ -1396,18 +1396,18 @@ function createCallStateProvider(func, funcCall, createGetValueIds, initCallStat
function _getCallState() {
// region getCallState
// region calc hash
var _valueIdsBuffer = valueIdsBuffer;
_valueIdsBuffer[0] = funcId;
valueIdsBufferLength = 1;
var valueIdsBufferStart = valueIdsBufferLength;
pushValueId(funcId);
var hash = funcHash;

if (!getValueIds.apply(this, arguments)) {
valueIdsBufferLength = valueIdsBufferStart;
return null;
}

var countValueStates = valueIdsBufferLength;
var _valueIdsBuffer = valueIdsBuffer;

for (var i = 1; i < countValueStates; i++) {
for (var i = valueIdsBufferStart + 1; i < valueIdsBufferLength; i++) {
var _valueId3 = _valueIdsBuffer[i];
hash = (0, _helpers.nextHash)(hash, _valueId3);
} // endregion
Expand All @@ -1417,10 +1417,11 @@ function createCallStateProvider(func, funcCall, createGetValueIds, initCallStat
var callStates = callStateHashTable.get(hash);

if (callStates != null) {
callState = findCallState(callStates, _valueIdsBuffer, countValueStates);
callState = findCallState(callStates, _valueIdsBuffer, valueIdsBufferLength - valueIdsBufferStart);
} // endregion


valueIdsBufferLength = valueIdsBufferStart;
return callState;
}

Expand All @@ -1435,20 +1436,19 @@ function createCallStateProvider(func, funcCall, createGetValueIds, initCallStat

function _getOrCreateCallState() {
// region getCallState
var countArgs = arguments.length; // region calc hash

var _valueIdsBuffer = valueIdsBuffer;
_valueIdsBuffer[0] = funcId;
valueIdsBufferLength = 1;
// region calc hash
var valueIdsBufferStart = valueIdsBufferLength;
pushValueId(funcId);
var hash = funcHash;
getOrCreateValueIds.apply(this, arguments);
var countValueStates = valueIdsBufferLength;
var _valueIdsBuffer = valueIdsBuffer;

for (var i = 1; i < countValueStates; i++) {
for (var i = valueIdsBufferStart + 1; i < valueIdsBufferLength; i++) {
var _valueId4 = _valueIdsBuffer[i];
hash = (0, _helpers.nextHash)(hash, _valueId4);
} // endregion
}

var countValueStates = valueIdsBufferLength - valueIdsBufferStart; // endregion

var callState;
var callStates = callStateHashTable.get(hash);
Expand All @@ -1459,23 +1459,25 @@ function createCallStateProvider(func, funcCall, createGetValueIds, initCallStat


if (callState != null) {
valueIdsBufferLength = valueIdsBufferStart;
return callState;
} // const valueIdsClone: Int32Array = _valueIdsBuffer.slice(0, countValueStates)


var valueIdsClone = new Int32Array(countValueStates);

for (var _i = 0; _i < countValueStates; _i++) {
valueIdsClone[_i] = _valueIdsBuffer[_i];
valueIdsClone[_i] = _valueIdsBuffer[valueIdsBufferStart + _i];
}

for (var _i2 = 0; _i2 < countValueStates; _i2++) {
if (_i2 > 0) {
var valueState = getValueState(_valueIdsBuffer[_i2]);
var valueState = getValueState(_valueIdsBuffer[valueIdsBufferStart + _i2]);
valueState.usageCount++;
}
}

valueIdsBufferLength = valueIdsBufferStart;
callState = new CallState(func, this, createCallWithArgs.apply(null, arguments), funcCall, valueIdsClone);
callStatesCount++;

Expand Down
36 changes: 19 additions & 17 deletions dist/mjs/main/common/rx/depend/core/CallState.js
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ export function deleteValueState(valueId, value) {
// region CallStateProviderState

let valueIdsBufferLength = 0;
const valueIdsBuffer = new Int32Array(100);
const valueIdsBuffer = [0];

function pushValueId(valueId) {
if (valueId === 0) {
Expand Down Expand Up @@ -1215,18 +1215,18 @@ export function createCallStateProvider(func, funcCall, createGetValueIds, initC
function _getCallState() {
// region getCallState
// region calc hash
const _valueIdsBuffer = valueIdsBuffer;
_valueIdsBuffer[0] = funcId;
valueIdsBufferLength = 1;
const valueIdsBufferStart = valueIdsBufferLength;
pushValueId(funcId);
let hash = funcHash;

if (!getValueIds.apply(this, arguments)) {
valueIdsBufferLength = valueIdsBufferStart;
return null;
}

const countValueStates = valueIdsBufferLength;
const _valueIdsBuffer = valueIdsBuffer;

for (let i = 1; i < countValueStates; i++) {
for (let i = valueIdsBufferStart + 1; i < valueIdsBufferLength; i++) {
const valueId = _valueIdsBuffer[i];
hash = nextHash(hash, valueId);
} // endregion
Expand All @@ -1236,10 +1236,11 @@ export function createCallStateProvider(func, funcCall, createGetValueIds, initC
const callStates = callStateHashTable.get(hash);

if (callStates != null) {
callState = findCallState(callStates, _valueIdsBuffer, countValueStates);
callState = findCallState(callStates, _valueIdsBuffer, valueIdsBufferLength - valueIdsBufferStart);
} // endregion


valueIdsBufferLength = valueIdsBufferStart;
return callState;
}

Expand All @@ -1254,20 +1255,19 @@ export function createCallStateProvider(func, funcCall, createGetValueIds, initC

function _getOrCreateCallState() {
// region getCallState
const countArgs = arguments.length; // region calc hash

const _valueIdsBuffer = valueIdsBuffer;
_valueIdsBuffer[0] = funcId;
valueIdsBufferLength = 1;
// region calc hash
const valueIdsBufferStart = valueIdsBufferLength;
pushValueId(funcId);
let hash = funcHash;
getOrCreateValueIds.apply(this, arguments);
const countValueStates = valueIdsBufferLength;
const _valueIdsBuffer = valueIdsBuffer;

for (let i = 1; i < countValueStates; i++) {
for (let i = valueIdsBufferStart + 1; i < valueIdsBufferLength; i++) {
const valueId = _valueIdsBuffer[i];
hash = nextHash(hash, valueId);
} // endregion
}

const countValueStates = valueIdsBufferLength - valueIdsBufferStart; // endregion

let callState;
let callStates = callStateHashTable.get(hash);
Expand All @@ -1278,23 +1278,25 @@ export function createCallStateProvider(func, funcCall, createGetValueIds, initC


if (callState != null) {
valueIdsBufferLength = valueIdsBufferStart;
return callState;
} // const valueIdsClone: Int32Array = _valueIdsBuffer.slice(0, countValueStates)


const valueIdsClone = new Int32Array(countValueStates);

for (let i = 0; i < countValueStates; i++) {
valueIdsClone[i] = _valueIdsBuffer[i];
valueIdsClone[i] = _valueIdsBuffer[valueIdsBufferStart + i];
}

for (let i = 0; i < countValueStates; i++) {
if (i > 0) {
const valueState = getValueState(_valueIdsBuffer[i]);
const valueState = getValueState(_valueIdsBuffer[valueIdsBufferStart + i]);
valueState.usageCount++;
}
}

valueIdsBufferLength = valueIdsBufferStart;
callState = new CallState(func, this, createCallWithArgs.apply(null, arguments), funcCall, valueIdsClone);
callStatesCount++;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webrain",
"version": "1.4.2-a",
"version": "1.4.3-a",
"description": "NodeJS cross-platform and cross-browser business logic framework - Brain of your web applications.",
"author": "Nikolay Makhonin",
"homepage": "https://github.com/NikolayMakhonin/webrain.js",
Expand Down
40 changes: 23 additions & 17 deletions src/main/common/rx/depend/core/CallState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ export function deleteValueState(valueId: number, value: any): void {
// region CallStateProviderState

let valueIdsBufferLength = 0
const valueIdsBuffer: Int32Array = new Int32Array(100)
const valueIdsBuffer: number[] = [0]
function pushValueId(valueId: number): boolean {
if (valueId === 0) {
return false
Expand Down Expand Up @@ -1429,7 +1429,7 @@ function findCallState<
TResultInner,
>(
callStates: Array<CallState<TThisOuter, TArgs, TResultInner>>,
_valueIdsBuffer: Int32Array,
_valueIdsBuffer: number[],
countValueStates: number,
) {
for (let i = 0, len = callStates.length; i < len; i++) {
Expand Down Expand Up @@ -1515,18 +1515,19 @@ export function createCallStateProvider<

// region calc hash

const _valueIdsBuffer = valueIdsBuffer
_valueIdsBuffer[0] = funcId
valueIdsBufferLength = 1
const valueIdsBufferStart = valueIdsBufferLength

pushValueId(funcId)
let hash = funcHash

if (!getValueIds.apply(this, arguments)) {
valueIdsBufferLength = valueIdsBufferStart
return null
}

const countValueStates = valueIdsBufferLength
const _valueIdsBuffer = valueIdsBuffer

for (let i = 1; i < countValueStates; i++) {
for (let i = valueIdsBufferStart + 1; i < valueIdsBufferLength; i++) {
const valueId = _valueIdsBuffer[i]
hash = nextHash(hash, valueId)
}
Expand All @@ -1536,11 +1537,13 @@ export function createCallStateProvider<
let callState: CallState<TThisOuter, TArgs, TResultInner>
const callStates = callStateHashTable.get(hash)
if (callStates != null) {
callState = findCallState(callStates, _valueIdsBuffer, countValueStates)
callState = findCallState(callStates, _valueIdsBuffer, valueIdsBufferLength - valueIdsBufferStart)
}

// endregion

valueIdsBufferLength = valueIdsBufferStart

return callState
}

Expand All @@ -1557,24 +1560,24 @@ export function createCallStateProvider<
function _getOrCreateCallState(this: TThisOuter) {
// region getCallState

const countArgs = arguments.length

// region calc hash

const _valueIdsBuffer = valueIdsBuffer
_valueIdsBuffer[0] = funcId
valueIdsBufferLength = 1
const valueIdsBufferStart = valueIdsBufferLength

pushValueId(funcId)
let hash = funcHash

getOrCreateValueIds.apply(this, arguments)

const countValueStates = valueIdsBufferLength
const _valueIdsBuffer = valueIdsBuffer

for (let i = 1; i < countValueStates; i++) {
for (let i = valueIdsBufferStart + 1; i < valueIdsBufferLength; i++) {
const valueId = _valueIdsBuffer[i]
hash = nextHash(hash, valueId)
}

const countValueStates = valueIdsBufferLength - valueIdsBufferStart

// endregion

let callState: CallState<TThisOuter, TArgs, TResultInner>
Expand All @@ -1586,22 +1589,25 @@ export function createCallStateProvider<
// endregion

if (callState != null) {
valueIdsBufferLength = valueIdsBufferStart
return callState
}

// const valueIdsClone: Int32Array = _valueIdsBuffer.slice(0, countValueStates)
const valueIdsClone = new Int32Array(countValueStates)
for (let i = 0; i < countValueStates; i++) {
valueIdsClone[i] = _valueIdsBuffer[i]
valueIdsClone[i] = _valueIdsBuffer[valueIdsBufferStart + i]
}

for (let i = 0; i < countValueStates; i++) {
if (i > 0) {
const valueState = getValueState(_valueIdsBuffer[i])
const valueState = getValueState(_valueIdsBuffer[valueIdsBufferStart + i])
valueState.usageCount++
}
}

valueIdsBufferLength = valueIdsBufferStart

callState = new CallState(
func,
this,
Expand Down

0 comments on commit 2a50690

Please sign in to comment.