[CalendarServer-changes] [329] CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 27 16:36:26 PDT 2006


Revision: 329
          http://trac.macosforge.org/projects/calendarserver/changeset/329
Author:   wsanchez at apple.com
Date:     2006-10-27 16:36:26 -0700 (Fri, 27 Oct 2006)

Log Message:
-----------
Exceptions are slow.

Modified Paths:
--------------
    CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch

Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch	2006-10-27 23:32:26 UTC (rev 328)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch	2006-10-27 23:36:26 UTC (rev 329)
@@ -85,7 +85,19 @@
      def _rememberURLForResource(self, url, resource):
          """
          Remember the URL of visited resources.
-@@ -385,8 +404,14 @@
+@@ -367,10 +386,7 @@
+ 
+         @return: the URL of C{resource} if known, otherwise C{None}.
+         """
+-        try:
+-            return self._resourcesByURL[resource]
+-        except KeyError:
+-            return None
++        return self._resourcesByURL.get(resource, None)
+ 
+     def locateResource(self, url):
+         """
+@@ -385,8 +401,13 @@
              The contained response will have a status code of
              L{responsecode.BAD_REQUEST}.
          """
@@ -93,15 +105,14 @@
 +        if url is None:
 +            return None
  
-+        try:
-+            return succeed(self._urlsByResource[url])
-+        except KeyError:
-+            pass
++        cached = self._urlsByResource.get(url, None)
++        if cached is not None:
++            return succeed(cached)
 +
          #
          # Parse the URL
          #
-@@ -414,11 +439,56 @@
+@@ -414,11 +435,56 @@
          def notFound(f):
              f.trap(http.HTTPError)
              if f.response.code != responsecode.NOT_FOUND:
@@ -135,11 +146,11 @@
 +        if res is None or childpath is None: return None
 +        
 +        url = joinURL(self.urlForResource(res), childpath)
-+        try:
-+            return succeed(self._urlsByResource[url])
-+        except KeyError:
-+            pass
 +
++        cached = self._urlsByResource.get(url, None)
++        if cached is not None:
++            return succeed(cached)
++
 +        segment = unquote(childpath)
 +
 +        def notFound(f):

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061027/6b381c28/attachment.html


More information about the calendarserver-changes mailing list