• Andrew Grieve's avatar
    Android: Change desugar to not cache stateless lambdas · 8a3a5c77
    Andrew Grieve authored
    Saves 15kb of dex and 300 dex methods by removing the <clinit>()
    from them.
    
    While it is sometimes a good idea to cache instances of inner
    classes, there are several reasons why having it be automatic
    is not a good idea:
    * Since caching happens only for stateless lambdas, it is
      too subtle. I don't think most devs are mindful of stateful
      vs. stateless lambdas when creating / modifying them. The
      syntax is the same for both.
    * Many lambdas are used only once. Adding in a <clinit>() adds
      synchronization overhead & an extra function call.
    
    Bug: 952833
    
    Change-Id: I9ab1474c93b2732954b6df5159ac89049f1bfcf1
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902476
    Auto-Submit: Andrew Grieve <agrieve@chromium.org>
    Commit-Queue: Sam Maier <smaier@chromium.org>
    Reviewed-by: default avatarSam Maier <smaier@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#714685}
    8a3a5c77
stateful-lambdas.patch 3.38 KB