gis-ops / valhalla-app

This is the demo web app running on https://valhalla.openstreetmap.de
https://valhalla.openstreetmap.de
MIT License
157 stars 87 forks source link

if else statements to switch #142

Closed DevMarioNan closed 1 year ago

DevMarioNan commented 1 year ago

turning the customSlider handle change function from an if else if statement to a switch statement

141# ๐Ÿ› ๏ธ Fixes Issue

Closes #141

๐Ÿ‘จโ€๐Ÿ’ป Changes proposed

in the CustomSlider.jsx component the handleChange function have some if else statements which slows down the process by a little bit

so i've changed it to a switch statement

the switch statement is faster in most cases when compared to if-else, but significantly faster only when the number of conditions is large. And It would help to make it more readable

๐Ÿ“„ Note to reviewers

the switch statement is faster in most cases when compared to if-else, but significantly faster only when the number of conditions is large. And It would help to make it more readable

nilsnolde commented 1 year ago

Yeah agreed. Thereโ€™s also no actual variable to switch over. It does need a โ€œelse ifโ€ but not necessarily a switch.