Author: vmassol
Date: 2008-02-26 20:38:36 +0100 (Tue, 26 Feb 2008)
New Revision: 7973

Modified:
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/SkinAction.java
Log:
Minor refactoring. Debug Log calls must be enclosed with a test for improved 
performances.

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/SkinAction.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/SkinAction.java
        2008-02-26 17:51:19 UTC (rev 7972)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/SkinAction.java
        2008-02-26 19:38:36 UTC (rev 7973)
@@ -73,15 +73,22 @@
         String baseskin = xwiki.getBaseSkin(context, true);
         XWikiDocument baseskindoc = xwiki.getDocument(baseskin, context);
         String defaultbaseskin = xwiki.getDefaultBaseSkin(context);
+
         String path = request.getPathInfo();
-        LOG.debug("document: " + doc.getFullName() + " ; baseskin: " + baseskin
-            + " ; defaultbaseskin: " + defaultbaseskin);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("document: " + doc.getFullName() + " ; baseskin: " + 
baseskin
+                + " ; defaultbaseskin: " + defaultbaseskin);
+        }
+        
         int idx = path.lastIndexOf(DELIMITER);
         boolean found = false;
         while (idx > 0) {
             try {
                 String filename = Util.decodeURI(path.substring(idx + 1), 
context);
-                LOG.debug("Trying '" + filename + "'");
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Trying '" + filename + "'");
+                }
 
                 if (renderSkin(filename, doc, context)) {
                     found = true;
@@ -128,7 +135,7 @@
      * XWikiSkins object attached to the document.</li>
      * <li>As the content of an attachment with the same name as the requested 
filename.</li>
      * <li>As a file located on the filesystem, in the directory with the same 
name as the current
-     * document (in case the URL was actually pointing to 
<tt>/skins/directory/file</tt>.</li>
+     * document (in case the URL was actually pointing to 
<tt>/skins/directory/file</tt>).</li>
      * </ol>
      * 
      * @param filename The name of the skin file that should be rendered.
@@ -140,13 +147,14 @@
     private boolean renderSkin(String filename, XWikiDocument doc, 
XWikiContext context)
         throws XWikiException
     {
-        LOG.debug("Rendering file '" + filename + "' within the '" + 
doc.getFullName()
-            + "' document");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Rendering file '" + filename + "' within the '" + 
doc.getFullName()
+                + "' document");
+        }
         try {
             if (doc.isNew()) {
-                LOG.debug(doc.getName() + " is not a document");
-                if (SKINS_DIRECTORY.equals(doc.getSpace())) {
-                    LOG.debug("Trying on the filesystem");
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug(doc.getName() + " is not a document");
                 }
             } else {
                 return renderFileFromObjectField(filename, doc, context)
@@ -176,8 +184,10 @@
     private boolean renderSkinFromFilesystem(String filename, String skin, 
XWikiContext context)
         throws XWikiException
     {
-        LOG.debug("Rendering filesystem file '" + filename + "' from the '" + 
skin
-            + "' skin directory");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Rendering filesystem file '" + filename + "' from the 
'" + skin
+                + "' skin directory");
+        }
         XWikiResponse response = context.getResponse();
         String path = DELIMITER + SKINS_DIRECTORY + DELIMITER + skin + 
DELIMITER + filename;
         try {

_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to