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

Don't use strings for BreadcrumbType in NDK #2018

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

lemnik
Copy link
Contributor

@lemnik lemnik commented Apr 16, 2024

Goal

Small reduction in overhead when leaving breadcrumbs: use integers to represent the BreadcrumbType instead of strings.

Design

While the string values for BreadcrumbType on the Java/Kotlin code were constants, they required a call to GetStringUTFChars and strcmp to evaluate which enum value to use.

The new implementation uses an exhaustive when which means:

  • the transfer values are not sensitive to the ordering of the enum values (as ordinal would be)
  • any adding or removing of enum values will cause compiler failures

Testing

Relied on existing tests.

@lemnik lemnik requested review from kstenerud and YYChen01988 April 16, 2024 10:44
@lemnik lemnik changed the title Don't allocate strings for BreadcrumbType Don't use strings for BreadcrumbType Apr 16, 2024
@lemnik lemnik changed the title Don't use strings for BreadcrumbType Don't use strings for BreadcrumbType in NDK Apr 16, 2024
@bugsnagbot
Copy link
Collaborator

bugsnagbot commented Apr 16, 2024

Android notifier sizes

Format Size impact of Bugsnag (kB) Size impact of Bugsnag when Minified (kB)
APK 1844.24 1668.28
arm64_v8a 626.95 450.82
armeabi_v7a 561.42 385.29
x86 704.75 524.53
x86_64 671.99 495.86

Generated by 🚫 Danger

@lemnik lemnik force-pushed the PLAT-11930/optimize-ndk-breadcrumb-type branch from 66f5df0 to 65c7631 Compare April 16, 2024 12:56
Copy link
Contributor

@YYChen01988 YYChen01988 left a comment

Choose a reason for hiding this comment

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

LGTM

@lemnik lemnik force-pushed the PLAT-11930/optimize-ndk-breadcrumb-type branch from 65c7631 to 94e7953 Compare April 16, 2024 13:42
@lemnik lemnik force-pushed the PLAT-11930/optimize-ndk-breadcrumb-type branch from 94e7953 to 9f23de0 Compare April 16, 2024 14:52
@lemnik lemnik merged commit a842c5d into next Apr 16, 2024
26 checks passed
@lemnik lemnik deleted the PLAT-11930/optimize-ndk-breadcrumb-type branch April 16, 2024 15:10
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.

4 participants