gis-ops / valhalla-app

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

Modify the customSlider handle change function #141

Closed andreyscott closed 1 year ago

andreyscott commented 1 year ago

Description

turning the customslider handle change function from an if else if statement 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

Screenshots

No response

Additional information

const handleChange = (value) => { //reset switch (true) { case isNaN(value): value = profile === 'truck' ? settingsInitTruckOverride[option.param] : settingsInit[option.param]; break; case value < min: value = min; break; case value > max: value = max; break; default: break }

  setSliderVal(parseFloat(value));

  debounce(
    300,
    handleUpdateSettings({
      name: option.param,
      value: parseFloat(value),
    })
  );
};
DevMarioNan commented 1 year ago

can you sign me to do it?