elm-community / webgl

Moved to elm-explorations/webgl
https://package.elm-lang.org/packages/elm-explorations/webgl/latest
BSD 3-Clause "New" or "Revised" License
131 stars 18 forks source link

Fix unnecessary linear-time emptiness check #50

Closed exists-forall closed 7 years ago

exists-forall commented 7 years ago

Previously, drawEntity checked if a buffer list was empty by computing its length and comparing it to zero. This required a linear-time traversal of the entire list. All that is really needed is to check if the list is empty or not, which can be done in constant time by checking if its constructor is [].

w0rm commented 7 years ago

@SelectricSimian good catch, thanks!