Skip to content

fix(android): reduce repeated work in getAllSupportedRegions#100

Open
higorlapacw wants to merge 1 commit into
acoutts:mainfrom
higorlapacw:fix/issue-97-android-region-warmup
Open

fix(android): reduce repeated work in getAllSupportedRegions#100
higorlapacw wants to merge 1 commit into
acoutts:mainfrom
higorlapacw:fix/issue-97-android-region-warmup

Conversation

@higorlapacw
Copy link
Copy Markdown

Summary

  • cache the digit regex used by maskNumber()
  • reuse a single PhoneNumberUtil instance inside getAllSupportedRegions()
  • format each example number once and reuse the result for both example values and masks

Why

getAllSupportedRegions() was doing avoidable repeated work for every supported region on Android:

  • recompiling the same digit regex for every mask generation
  • calling PhoneNumberUtil.getInstance() repeatedly inside the loop
  • formatting the same example numbers multiple times before masking them

This keeps behavior the same while reducing allocations and duplicated work in the Android warm-up path.

Validation

  • flutter pub get
  • flutter analyze packages/flutter_libphonenumber_android

Refs #97

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.

1 participant