diff MoinMoin/action/rss_rc.py @ 5992:f8bb40fb3ac4

rss_rc action: optimize single page performance a lot
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 08 Jun 2013 03:45:14 +0200
parents aee4ff651134
children 6de72050e1b9
line wrap: on
line diff
--- a/MoinMoin/action/rss_rc.py	Sat Jun 08 02:31:32 2013 +0200
+++ b/MoinMoin/action/rss_rc.py	Sat Jun 08 03:45:14 2013 +0200
@@ -38,6 +38,17 @@
     else:
         return pagename == page_pattern
 
+def is_single_page_match(page_pattern):
+    # note: keep this code in sync with match_page()!
+    if not page_pattern:
+        return False
+    elif page_pattern[0] == "^":
+        return False
+    elif page_pattern.endswith("/"):
+        return False
+    else:
+        return True
+
 def execute(pagename, request):
     """ Send recent changes as an RSS document
     """
@@ -92,8 +103,11 @@
     except ValueError:
         pass
 
-    # get data
-    log = editlog.EditLog(request)
+    # if we are just interested in a specific page, using the local edit-log
+    # of that page is much faster than the global one - esp. if the page was
+    # NOT recently changed and the global edit-log is rather big.
+    kw = dict(rootpagename=page_pattern) if is_single_page_match(page_pattern) else {}
+    log = editlog.EditLog(request, **kw)
     logdata = []
     counter = 0
     pages = {}