Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2: Remove addListItem and setMapEntry from ReflectMessage #875

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

timostamm
Copy link
Member

The type ReflectMessage includes methods for adding list items and map entries. For example:

reflectMsg.addListItem(listField, "Springfield");
reflectMsg.setMapEntry(mapField, "SPP", "Springfield Power Plant");

The purpose of the methods is to provide a fast path that does not require the creation of a ReflectList or ReflectMap object with ReflectMessage.get:

reflectMsg.get(listField).add("Springfield");
reflectMsg.get(mapField).set("SPP", "Springfield Power Plant");

But it turns out that we get nearly the same performance in practical use cases by caching ReflectList and ReflectMap objects:

- fromBinary perf-payload.bin x 7,037 ops/sec ±0.17% (101 runs sampled)
+ fromBinary perf-payload.bin x 6,924 ops/sec ±0.21% (98 runs sampled)

Depending on the use case, the performance regression is about 1,5%. Since the API is much cleaner without the fast path methods, this PR removes them.

@timostamm timostamm merged commit 2e4a5f0 into v2 Jun 3, 2024
6 checks passed
@timostamm timostamm deleted the tstamm/simplify-reflect branch June 3, 2024 16:21
@timostamm timostamm changed the title Remove addListItem and setMapEntry from ReflectMessage V2: Remove addListItem and setMapEntry from ReflectMessage Jun 4, 2024
@timostamm timostamm mentioned this pull request Jun 4, 2024
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