Refactoring and optimization #75
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Насколько удалось протестировать, изменения не меняют поведения программы - это, по большей части, только рефакторинг и оптимизации
Пару комментариев:
059b061 - Remove redundant conditions
Во всех этих ситуациях значения можно сбрасывать без их предварительной проверки - результат будет один и тот же
13c4bf7 - Optimize and simplify
MultiButton.h -
bool tick(T0& b0, T1& b1)
дублирует код изbool VirtButton::tick(VirtButton& b0, VirtButton& b1)
, не хватает толькоb0.call()
иb1.call()
VirtEncoder.h - Аналогично с
int8_t tickRaw(const bool e0, const bool e1)
иint8_t tickISR(const bool e0, const bool e1)
VirtEncButton.h - В
bool _tickRaw(bool btn, int8_t estate)
можно обойтись без флагаencf
Остальное:
T0
иT1
никак не подсказывают, объектами каких классов они могут быть. Тут же проблемы отсутстувия подсветки синтаксиса, эльфийские сообщения комплиятора, если есть ошибки с этим классом, и запутанная ситуация с практической разницей междуMultiButton::tick(T0& b0, T1& b1)
иVirtButton::tick(VirtButton& b0, VirtButton& b1)
. Как пример того, что проблема существенная, это ошибка в README:EncButton/README.md
Line 1120 in 489c34a
Попытка передать
VirtButton
вMultiButton
приводит к ошибке, т.к. уVirtButton
нет методаtickRaw()
, толькоtickRaw(const bool s)
:Button/ButtonT
иEncButton/EncButtonT
(в таком случае, возможно, стоило бы сделать то же самое и с классом энкодера)readEnc
дляEncButton/EncButtonT
, которого не существует:EncButton/README.md
Lines 228 to 230 in 489c34a
EncButton/README.md
Lines 615 to 616 in 489c34a
Cоответственно, следует либо добавить его в код, либо убрать его из README