Closed papperone closed 7 years ago
Looking some plugins code for learning I realized that some optimization can be performed here and there. Here's an example in the BH1750 plugin:
sensors_resolution_t mode; if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_LOW) mode = RESOLUTION_LOW; if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_NORMAL) mode = RESOLUTION_NORMAL; if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_HIGH) mode = RESOLUTION_HIGH; if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_AUTO_HIGH) mode = RESOLUTION_AUTO_HIGH;
sensors_resolution_t mode;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_LOW) mode = RESOLUTION_LOW;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_NORMAL) mode = RESOLUTION_NORMAL;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_HIGH) mode = RESOLUTION_HIGH;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_AUTO_HIGH) mode = RESOLUTION_AUTO_HIGH;
which IMHO can be replaced by just 2 lines below: sensors_resolution_t mode; mode = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
mode = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
Can I submit those as Pull Requests? I ask as I don't want to mess up with who actually wrote and maintain each plugin.
thats strange code indeed. maybe its leftover when the code was doing something extra. you can create a pull request if you like.
Looking some plugins code for learning I realized that some optimization can be performed here and there. Here's an example in the BH1750 plugin:
sensors_resolution_t mode;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_LOW) mode = RESOLUTION_LOW;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_NORMAL) mode = RESOLUTION_NORMAL;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_HIGH) mode = RESOLUTION_HIGH;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]==RESOLUTION_AUTO_HIGH) mode = RESOLUTION_AUTO_HIGH;
which IMHO can be replaced by just 2 lines below:
sensors_resolution_t mode;
mode = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
Can I submit those as Pull Requests? I ask as I don't want to mess up with who actually wrote and maintain each plugin.