logo       


[xmlc] Minor optimization (though used rather a lot): msg#00000

Subject: [xmlc] Minor optimization (though used rather a lot)
Someone still working on XMLC? :-)

Trivial optimization to remove duplicate getAttribute() call - usually
a HashTable lookup.

Final code (exclusive of long comment) reduced to:
---------------------------------------
    public static XMLCContext getContext(ServletContext servletContext) {
        XMLCContext context =
(XMLCContext)servletContext.getAttribute(CONTEXT_ATTRIBUTE);
        if (null != context) {
            return context;
        }
        context = new XMLCContextInit().createContext(servletContext);
        servletContext.setAttribute(CONTEXT_ATTRIBUTE, context);
        return context;
    }
---------------------------------------


Index: XMLCContext.java
===================================================================
RCS file: 
/cvsroot/xmlc/xmlc/xmlc/modules/xmlc/src/org/enhydra/xml/xmlc/servlet/XMLCContext.java,v
retrieving revision 1.5
diff -u -r1.5 XMLCContext.java
--- XMLCContext.java    26 Jan 2005 08:29:24 -0000    1.5
+++ XMLCContext.java    1 Jul 2005 10:42:16 -0000
@@ -534,11 +534,12 @@
         //reasonable and shouldn't cause problems since the only
worry about resetting the
         //XMLCContext object is performance.  No real need for
synchronization. --Jake
         XMLCContext context =
(XMLCContext)servletContext.getAttribute(CONTEXT_ATTRIBUTE);
-        if (context == null) {
-            context = new XMLCContextInit().createContext(servletContext);
-            servletContext.setAttribute(CONTEXT_ATTRIBUTE, context);
+        if (null != context) {
+            return context;
         }
-        return (XMLCContext)servletContext.getAttribute(CONTEXT_ATTRIBUTE);
+        context = new XMLCContextInit().createContext(servletContext);
+        servletContext.setAttribute(CONTEXT_ATTRIBUTE, context);
+        return context;
     }

--
You receive this message as a subscriber of the xmlc@xxxxxxxxxxxxx mailing list.
To unsubscribe: mailto:xmlc-unsubscribe@xxxxxxxxxxxxx
For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosting, windows, cisco ...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe