You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Alexander Klimetschek (JIRA)" <ji...@apache.org> on 2009/03/04 12:05:56 UTC

[jira] Commented: (SLING-877) Avoid calling Locale.getAvailableLocales() because it is very slow

    [ https://issues.apache.org/jira/browse/SLING-877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678689#action_12678689 ] 

Alexander Klimetschek commented on SLING-877:
---------------------------------------------

toLocale() is only called during the component activation to set the default
locale based on the component configuration. I can imagine two optimizations:

a) make this lazy-loading (not sure when this might be called):

   private Locale internalGetDefaultLocale() {
       if (this.defaultLocale == null) {
           this.defaultLocale = toLocale(localeString);
       }
   }

b) since in most cases the default locale will be english anyway, a simple
   check could skip toLocale() and the performance intensive
   Locale.getAvailableLocales() completely:

   if ("en".equals(localeString)) {
       this.defaultLocale = Locale.ENGLISH;
   } else {
       this.defaultLocale = internalGetDefaultLocale();
   }

> Avoid calling Locale.getAvailableLocales() because it is very slow
> ------------------------------------------------------------------
>
>                 Key: SLING-877
>                 URL: https://issues.apache.org/jira/browse/SLING-877
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Thomas Mueller
>
> Currently, JcrResourceBundleProvider.toLocale calls Locale.getAvailableLocales().
> The first call to this method is very slow (3.4 seconds on my machine) because
> it scans many jar files.
> http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java?view=markup
> It looks like calling this method is not required.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.