MindBuffer / cohen_gig

Wash lighting and LED visualisation and DMX control for the upcoming Josh Cohen gig.
3 stars 1 forks source link

"Shader name" string argument on shader function could just be an enum field in the `Uniforms` struct. #17

Closed mitchmindtree closed 5 years ago

mitchmindtree commented 5 years ago

Just a heads up for future reference as it's never a good idea to match on strings for a couple of reasons:

  1. More expensive to match on every character in a string rather than a single enum value.
  2. Easy to make typos that won't get caught at compile time.
JoshuaBatty commented 5 years ago

Yeah cool I wanted to talk to you about how you would have gone about this as I was aware of the two points you brought up but couldn't work out how to avoid them. Specifically how can I have an enum that represents all the different shaders, but then have the names of that enum populate a conrod DDL. It seemed that to have the names in there I need to create a vector of strings to pass in and because of that, I was going to have to match on that to then decide the value of the enum.... so ended up just string with stings instead of having strings and enums.