Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-3571

Light optimization for CachingNameResolver.getJCRName(Name)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.2.13, 2.4.3, 2.5.3, 2.6
    • 2.7
    • jackrabbit-spi-commons
    • None

    Description

      In case of a Name which has no namespace (name.getNamespaceURI().length() == 0) there is perhaps no need to cache the resolved jcrName as it will be getLocalName().

      If this is true, than I would like to suggest the following slight optimization in the org.apache.jackrabbit.spi.commons.conversion.CachingNameResolver.getJCRName(Name) method:

      public String getJCRName(Name name) throws NamespaceException {
      if (name.getNamespaceURI().length() == 0)

      { return name.getLocalName(); }

      String jcrName = (String) cache.get(name);
      ...

      This will return earlier and "save" the lookup in the cache and further cache.put() (the GenerationalCache.put(Object, Object) is synchronized so avoiding the call makes things potentially faster).

      Thank you in advance!

      Attachments

        1. CachingNameResolver.patch
          0.8 kB
          Sergiy Shyrkov

        Activity

          People

            Unassigned Unassigned
            shyrkov Sergiy Shyrkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: