You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2002/03/22 12:52:17 UTC

DO NOT REPLY [Bug 7361] New: - Performance Enhancement to MessageResouce.getMessage(..)

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7361>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7361

Performance Enhancement to MessageResouce.getMessage(..)

           Summary: Performance Enhancement to MessageResouce.getMessage(..)
           Product: Struts
           Version: 1.1 Beta 1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Standard Actions
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: rs@match.at


the following snippet is much faster then the internal caching.

because there is no key to build up and only 1 Object will be created 
instead of 4. 

it is about 4 times faster (meassured with JProbe profiler).


... extends MessageResources
{

    public String getMessage(Locale locale, String key)
    {
        HashMap messageMap = (HashMap)messageLocaleMaps.get(locale);
        if (messageMap == null)
        {
            messageMap = new HashMap();
            messageLocaleMaps.put(locale, messageMap);
        }
        String message = (String)messageMap.get(key);
        if (message == null)
        {
            message = super.getMessage(locale, key);
            messageMap.put(key, message);
        }
        return message;
    }

}

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>