davidrapan / ha-solarman

⚡ Solarman Stick Logger integration for 🏠 Home Assistant
MIT License
115 stars 25 forks source link

refactor: Optimize parsing #42

Closed sofkaski closed 4 months ago

sofkaski commented 4 months ago

While working with PR #35 I noticed one opportunity to optimize parsing. The idea is in the commit message of this PR:

Call field parsing only if the (first) register in the parameter definition is within the range of raw data queried from the device. The change reduces somewhat processing overhead, by avoiding extra function calls.

All definitions are looped through for each received raw data buffer. Without this change rule specific parsers were called even if data for the register in the definition is not in the raw data buffer being parsed. That condition is discovered in rule specific parsers and parsing attempt rejected only there.

davidrapan commented 4 months ago

Hi @sofkaski, LGTM.

Thanks and welcome between the contributors!