Skip to content

Commit 71fa13b

Browse files
Merge pull request #271 from gpujs/270-falsey
fix, test, bump version number, and make.
2 parents ef18f2c + 7898fed commit 71fa13b

File tree

9 files changed

+31
-27
lines changed

9 files changed

+31
-27
lines changed

bin/gpu-core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 1.0.3
8-
* @date Wed Feb 28 2018 22:04:12 GMT-0500 (EST)
7+
* @version 1.0.4
8+
* @date Thu Mar 01 2018 15:56:51 GMT-0500 (EST)
99
*
1010
* @license MIT
1111
* The MIT License

bin/gpu-core.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/gpu.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 1.0.3
8-
* @date Wed Feb 28 2018 22:04:13 GMT-0500 (EST)
7+
* @version 1.0.4
8+
* @date Thu Mar 01 2018 15:56:51 GMT-0500 (EST)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -3211,12 +3211,10 @@ module.exports = function (_KernelBase) {
32113211
}, {
32123212
key: 'getUniformLocation',
32133213
value: function getUniformLocation(name) {
3214-
var location = this.programUniformLocationCache[name];
3215-
if (!location) {
3216-
location = this._webGl.getUniformLocation(this.program, name);
3217-
this.programUniformLocationCache[name] = location;
3214+
if (this.programUniformLocationCache.hasOwnProperty(name)) {
3215+
return this.programUniformLocationCache[name];
32183216
}
3219-
return location;
3217+
return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name);
32203218
}
32213219

32223220

bin/gpu.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/backend/web-gl/kernel.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,10 @@ module.exports = function (_KernelBase) {
571571
}, {
572572
key: 'getUniformLocation',
573573
value: function getUniformLocation(name) {
574-
var location = this.programUniformLocationCache[name];
575-
if (!location) {
576-
location = this._webGl.getUniformLocation(this.program, name);
577-
this.programUniformLocationCache[name] = location;
574+
if (this.programUniformLocationCache.hasOwnProperty(name)) {
575+
return this.programUniformLocationCache[name];
578576
}
579-
return location;
577+
return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name);
580578
}
581579

582580
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gpu.js",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "GPU Accelerated JavaScript",
55
"main": "./dist/index.js",
66
"directories": {

src/backend/web-gl/kernel.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,12 +532,10 @@ module.exports = class WebGLKernel extends KernelBase {
532532
*
533533
*/
534534
getUniformLocation(name) {
535-
let location = this.programUniformLocationCache[name];
536-
if (!location) {
537-
location = this._webGl.getUniformLocation(this.program, name);
538-
this.programUniformLocationCache[name] = location;
535+
if (this.programUniformLocationCache.hasOwnProperty(name)) {
536+
return this.programUniformLocationCache[name];
539537
}
540-
return location;
538+
return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name);
541539
}
542540

543541
/**

test/html/test-all.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@
5757
<script src="../src/issues/259-atan2.js"></script>
5858
<script src="../src/issues/263-to-string.js"></script>
5959
<script src="../src/issues/267-immutable-sub-kernels.js"></script>
60+
<script src="../src/issues/270-cache.js"></script>
6061
</body>
6162
</html>

test/src/issues/270-cache.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
QUnit.test('Issue #270 WebGlKernel getUniformLocation caches falsey - gpu', () => {
2+
const kernel = new GPU.WebGLKernel('', {});
3+
kernel.programUniformLocationCache.test = false;
4+
kernel._webGl = {};
5+
kernel._webGl.getUniformLocation = () => {
6+
throw new Error('tried to get getUniformLocation when falsey');
7+
};
8+
QUnit.assert.equal(kernel.getUniformLocation('test'), false);
9+
});

0 commit comments

Comments
 (0)