Skip to content

Conversation

@amcrn
Copy link

@amcrn amcrn commented Nov 7, 2017

  • KeyUtil.getKeyBytes(String) was being called twice for every Key,
    causing unnecessary byte[] allocations.
  • flags is more often than not 0, therefore send 0 as a String vs.
    an int to avoid autoboxing the int to an Integer and requiring
    unnecessary String.valueOf(Integer) + Integer.toString()
    allocations.
  • exp is commonly 0 (for never expire), and therefore send 0 as a
    String vs. an int to avoid the same issue mentioned above for
    flags.

If flags is 0 and exp is 0, ~10% less garbage is allocated as a
result of this optimization.

* KeyUtil.getKeyBytes(String) was being called twice for every Key,
  causing unnecessary byte[] allocations.
* flags is more often than not 0, therefore send 0 as a String vs.
  an int to avoid autoboxing the int to an Integer and requiring
  unnecessary String.valueOf(Integer) + Integer.toString()
  allocations.
* exp is commonly 0 (for never expire), and therefore send 0 as a
  String vs. an int to avoid the same issue mentioned above for
  flags.

If flags is 0 and exp is 0, ~10% less garbage is allocated as a
result of this optimization.
@ingenthr ingenthr self-assigned this Mar 27, 2018
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