Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Cache MAX_TEXTURE_SIZE #1312

Merged
merged 2 commits into from
Oct 12, 2018
Merged

Cache MAX_TEXTURE_SIZE #1312

merged 2 commits into from
Oct 12, 2018

Conversation

annxingyuan
Copy link
Collaborator

@annxingyuan annxingyuan commented Oct 12, 2018

This PR addresses the issue tensorflow/tfjs#786 by caching the value of MAX_TEXTURE_SIZE within the function that queries the WebGL context.

BUG


For repository owners only:

Please remember to apply all applicable tags to your pull request.
Tags: FEATURE, BREAKING, BUG, PERF, DEV, DOC, SECURITY

For more info see: /~https://github.com/tensorflow/tfjs/blob/master/DEVELOPMENT.md


This change is Reviewable

@annxingyuan annxingyuan self-assigned this Oct 12, 2018
Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1.
Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @annxingyuan, @nsthorat, and @dsmilkov)


src/environment_util.ts, line 118 at r1 (raw file):

}

export const getWebGLMaxTextureSize = (() => {

no need to do this with a closure you can let the MAX_TEXTURE_SIZE live at the top level


src/environment_util.ts, line 122 at r1 (raw file):

  // unit tests and we don't want to constantly query the WebGLContext for
  // MAX_TEXTURE_SIZE.
  let MAX_TEXTURE_SIZE: number = null;

for consistency with other places we do this don’t set it to null just leave it not defined


src/environment_util.ts, line 124 at r1 (raw file):

  let MAX_TEXTURE_SIZE: number = null;
  return (webGLVersion: number, isBrowser: boolean): number => {
    if (MAX_TEXTURE_SIZE === null) {

prefer double equals over triple equals for null checks. double equals null also checks for undefined

@annxingyuan annxingyuan merged commit 591f0a6 into master Oct 12, 2018
@annxingyuan annxingyuan deleted the cache_max_texture_size branch October 12, 2018 17:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants