Skip to content

Commit

Permalink
Merge branch 'FLUID-6756' into main
Browse files Browse the repository at this point in the history
* FLUID-6756:
  FLUID-6756: move global framework functions to fluid namespace
  • Loading branch information
amb26 committed Nov 25, 2022
2 parents 735bc6d + 32edd9d commit f968fa3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
22 changes: 15 additions & 7 deletions src/framework/core/js/Fluid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2346,25 +2346,33 @@ fluid.mergeOneImpl = function (thisTarget, thisSource, j, sources, newPolicy, ne
}
return togo;
};

// NB - same quadratic worry about these as in FluidIoC in the case the RHS trundler is live -
// since at each regeneration step driving the RHS we are discarding the "cursor arguments" these
// would have to be regenerated at each step - although in practice this can only happen once for
// each object for all time, since after first resolution it will be concrete.
function regenerateCursor(source, segs, limit, sourceStrategy) {
//
// TODO: This method is unnecessary and will quadratic inefficiency if RHS block is not concrete.
// The driver should detect "homogeneous uni-strategy trundling" and agree to preserve the extra
// "cursor arguments" which should be advertised somehow (at least their number)
//
// unsupported, NON-API function
fluid.regenerateCursor = function (source, segs, limit, sourceStrategy) {
for (var i = 0; i < limit; ++i) {
source = sourceStrategy(source, segs[i], i, fluid.makeArray(segs)); // copy for FLUID-5243
}
return source;
}
};

function regenerateSources(sources, segs, limit, sourceStrategies) {
// unsupported, NON-API function
fluid.regenerateSources = function (sources, segs, limit, sourceStrategies) {
var togo = [];
for (var i = 0; i < sources.length; ++i) {
var thisSource = regenerateCursor(sources[i], segs, limit, sourceStrategies[i]);
var thisSource = fluid.regenerateCursor(sources[i], segs, limit, sourceStrategies[i]);
togo.push(thisSource);
}
return togo;
}
};

// unsupported, NON-API function
fluid.fetchMergeChildren = function (target, i, segs, sources, mergePolicy, options) {
Expand Down Expand Up @@ -2431,8 +2439,8 @@ fluid.makeMergeStrategy = function (options) {
}
if (sources === undefined) { // recover our state in case this is an external entry point
segs = fluid.makeArray(segs); // avoid trashing caller's segs
sources = regenerateSources(options.sources, segs, i - 1, options.sourceStrategies);
policy = regenerateCursor(options.mergePolicy, segs, i - 1, fluid.concreteTrundler);
sources = fluid.regenerateSources(options.sources, segs, i - 1, options.sourceStrategies);
policy = fluid.regenerateCursor(options.mergePolicy, segs, i - 1, fluid.concreteTrundler);
}
var newPolicyHolder = fluid.concreteTrundler(policy, name);
var newPolicy = fluid.derefMergePolicy(newPolicyHolder);
Expand Down
15 changes: 2 additions & 13 deletions src/framework/core/js/FluidIoC.js
Original file line number Diff line number Diff line change
Expand Up @@ -3235,17 +3235,6 @@ fluid.fetchExpandChildren = function (target, i, segs, source, mergePolicy, opti
return target;
};

// TODO: This method is unnecessary and will quadratic inefficiency if RHS block is not concrete.
// The driver should detect "homogeneous uni-strategy trundling" and agree to preserve the extra
// "cursor arguments" which should be advertised somehow (at least their number)
function regenerateCursor(source, segs, limit, sourceStrategy) {
for (var i = 0; i < limit; ++i) {
// copy segs to avoid aliasing with FLUID-5243
source = sourceStrategy(source, segs[i], i, fluid.makeArray(segs));
}
return source;
}

fluid.isUnexpandable = function (source) { // slightly more efficient compound of fluid.isCopyable and fluid.isComponent - review performance
return fluid.isPrimitive(source) || !fluid.isPlainObject(source);
};
Expand Down Expand Up @@ -3300,8 +3289,8 @@ fluid.makeExpandStrategy = function (options) {
return target[name];
}
if (source === undefined) { // recover our state in case this is an external entry point
source = regenerateCursor(options.source, segs, i - 1, options.sourceStrategy);
policy = regenerateCursor(options.mergePolicy, segs, i - 1, fluid.concreteTrundler);
source = fluid.regenerateCursor(options.source, segs, i - 1, options.sourceStrategy);
policy = fluid.regenerateCursor(options.mergePolicy, segs, i - 1, fluid.concreteTrundler);
}
var thisSource = options.sourceStrategy(source, name, i, segs);
var thisPolicy = fluid.concreteTrundler(policy, name);
Expand Down

0 comments on commit f968fa3

Please sign in to comment.