Skip to content

Commit

Permalink
avoid repeatedly recreating empty static program configs (#3491)
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner authored Oct 31, 2016
1 parent 3f1b490 commit fa645d9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Painter {
{name: 'u_color', components: 4},
{name: 'u_opacity', components: 1}
]);
this.emptyProgramConfiguration = ProgramConfiguration.createStatic([]);
}

/*
Expand Down Expand Up @@ -369,7 +370,7 @@ class Painter {

_createProgramCached(name, paintAttributeSet) {
this.cache = this.cache || {};
const key = `${name}:${paintAttributeSet.cacheKey}:${this._showOverdrawInspector}`;
const key = `${name}${paintAttributeSet.cacheKey}${!!this._showOverdrawInspector}`;
if (!this.cache[key]) {
this.cache[key] = paintAttributeSet.createProgram(name, this._showOverdrawInspector, this.gl);
}
Expand All @@ -380,7 +381,7 @@ class Painter {
const gl = this.gl;

const nextProgram = this._createProgramCached(name,
paintAttributeSet || ProgramConfiguration.createStatic([]));
paintAttributeSet || this.emptyProgramConfiguration);
const previousProgram = this.currentProgram;

if (previousProgram !== nextProgram) {
Expand Down

0 comments on commit fa645d9

Please sign in to comment.