Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-33897

MediaQueryParser should not allocate memory for expressions already cached

    XMLWordPrintableJSON

Details

    Description

      When using @media from default sdk styles or custom styles
      the mxml compiler generates code like :

      if (styleManager.acceptMediaList("(application-dpi:160)"))
      {
      this.focusThickness = 3;
      this.fontSize = 24;
      }
      if (styleManager.acceptMediaList("(application-dpi:320)"))
      {
      this.fontSize = 24;
      }
      if (styleManager.acceptMediaList("(application-dpi:480)"))
      {
      this.focusThickness = 3;
      this.fontSize = 24;
      }
      ...

      The acceptMediaList is often called, it delegates to MediaQueryParser which has a cache of known media expressions.
      But MediaQueryParser#parse allocates some memory even if the expression is in the cache. these allocations come from the string manipulation.

      this patch use the original expression as the key in the cache instead of the 'lowercased' expression.
      It will increase the cache size (by a small percentage) only if you have the same media expression in different case.

      Attachments

        1. mediaquery-example-1.png
          114 kB
          Benoit Wiart
        2. 0001-MediaQury-parser-optimization.patch
          3 kB
          Benoit Wiart

        Activity

          People

            jmclean Justin Mclean
            benoitw Benoit Wiart
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: