Skip to content

Prevent unnecessary reallocs#384

Merged
Miq1 merged 1 commit into
eModbus:masterfrom
monsieurvor:realloc-fix
Jan 10, 2025
Merged

Prevent unnecessary reallocs#384
Miq1 merged 1 commit into
eModbus:masterfrom
monsieurvor:realloc-fix

Conversation

@monsieurvor

Copy link
Copy Markdown
Contributor

The current implementation of ModbusMessage::add(const uint8_t *arrayOfBytes, uint16_t count) used by the ModbusClients reallocates memory for every byte in the array being added through push_back. This change reduces that to a single resize operation.

Tested on ESP32 S3

The current implementation of `add(const uint8_t *arrayOfBytes, uint16_t count)` used by the ModbusClients reallocates dynamic memory for every byte in the data array being added through `push_back`.
This change reduces that to a single resize operation.

@Miq1 Miq1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@Miq1 Miq1 merged commit 331b9e6 into eModbus:master Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants