incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [27/50] git commit: [#6735] Don't compute md5 unless necessary
Date Wed, 23 Oct 2013 12:57:04 GMT
[#6735] Don't compute md5 unless necessary

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c5889c8e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c5889c8e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c5889c8e

Branch: refs/heads/tv/6610
Commit: c5889c8ee6792090c6a429929f50151b0c3e3d96
Parents: c58230f
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue Oct 15 21:22:37 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue Oct 15 21:29:05 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c5889c8e/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 083083a..4fb96b8 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -95,9 +95,11 @@ class ForgeMarkdown(markdown.Markdown):
                     field_name, artifact.__class__.__name__)
             return self.convert(source_text)
 
-        md5 = hashlib.md5(source_text).hexdigest()
-        if cache.md5 == md5:
-            return cache.html
+        md5 = None
+        if cache.md5 is not None:
+            md5 = hashlib.md5(source_text).hexdigest()
+            if cache.md5 == md5:
+                return cache.html
 
         start = time.time()
         html = self.convert(source_text)
@@ -112,6 +114,8 @@ class ForgeMarkdown(markdown.Markdown):
                     '"markdown_cache_threshhold" must be a float.')
 
         if threshhold != None and render_time > threshhold:
+            if md5 is None:
+                md5 = hashlib.md5(source_text).hexdigest()
             cache.md5, cache.html, cache.render_time = md5, html, render_time
         return html
 


Mime
View raw message