Skip to content

Cache expensive allocations and simplify collection idioms#112

Open
cantgetpastmesa wants to merge 1 commit into
ProtonMail:mainfrom
cantgetpastmesa:perf/micro-optimizations
Open

Cache expensive allocations and simplify collection idioms#112
cantgetpastmesa wants to merge 1 commit into
ProtonMail:mainfrom
cantgetpastmesa:perf/micro-optimizations

Conversation

@cantgetpastmesa

Copy link
Copy Markdown
  • Hoist NSRegularExpression, JSONEncoder, and DateFormatter instances to module scope so they are not re-created on every call.
  • Replace filter().count, filter().isEmpty, and count > 0 patterns with count(where:), contains(where:), and !isEmpty respectively to avoid allocating intermediate arrays on hot paths (recipient field input, sidebar selection, mailbox list cell rendering, composer attachment counting).

- Hoist NSRegularExpression, JSONEncoder, and DateFormatter instances
  to module scope so they are not re-created on every call.
- Replace filter().count, filter().isEmpty, and count > 0 patterns
  with count(where:), contains(where:), and !isEmpty respectively
  to avoid allocating intermediate arrays on hot paths (recipient
  field input, sidebar selection, mailbox list cell rendering,
  composer attachment counting).
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