mirror of
https://github.com/photonstorm/phaser
synced 2024-11-28 15:41:37 +00:00
Merge pull request #3448 from jamierocks/no-eval
Remove string-generated Functions for CSP policies
This commit is contained in:
commit
72eca92e4d
1 changed files with 18 additions and 13 deletions
|
@ -467,20 +467,25 @@ rbush.prototype = {
|
||||||
{
|
{
|
||||||
// data format (minX, minY, maxX, maxY accessors)
|
// data format (minX, minY, maxX, maxY accessors)
|
||||||
|
|
||||||
// uses eval-type function compilation instead of just accepting a toBBox function
|
// Do not use string-generated Functions for CSP policies
|
||||||
// because the algorithms are very sensitive to sorting functions performance,
|
// Instead a combination of anonymous functions and grabbing
|
||||||
// so they should be dead simple and without inner calls
|
// properties by string is used.
|
||||||
|
var compareArr = function(accessor) {
|
||||||
|
return function(a, b) {
|
||||||
|
return this[a + accessor] - this[b + accessor];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
this.compareMinX = compareArr(format[0]);
|
||||||
|
this.compareMinY = compareArr(format[1]);
|
||||||
|
|
||||||
var compareArr = ['return a', ' - b', ';'];
|
this.toBBox = function (a) {
|
||||||
|
return {
|
||||||
this.compareMinX = new Function('a', 'b', compareArr.join(format[0]));
|
minX: a + format[0],
|
||||||
this.compareMinY = new Function('a', 'b', compareArr.join(format[1]));
|
minY: a + format[1],
|
||||||
|
maxX: a + format[2],
|
||||||
this.toBBox = new Function('a',
|
maxy: a + format[3]
|
||||||
'return {minX: a' + format[0] +
|
};
|
||||||
', minY: a' + format[1] +
|
};
|
||||||
', maxX: a' + format[2] +
|
|
||||||
', maxY: a' + format[3] + '};');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue