changeset 551:17ab8fe4a94b

refactored some d.has_key(k) to k in d (faster) imported from: moin--main--1.5--patch-555
author Thomas Waldmann <tw@waldmann-edv.de>
date Tue, 11 Apr 2006 09:59:11 +0000
parents 24c87a2cd368
children 7d46743be355
files ChangeLog MoinMoin/Page.py MoinMoin/action/Despam.py MoinMoin/action/links.py MoinMoin/i18n/__init__.py MoinMoin/macro/OrphanedPages.py MoinMoin/macro/RecentChanges.py MoinMoin/macro/WantedPages.py MoinMoin/script/account/check.py
diffstat 9 files changed, 36 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 11 09:38:38 2006 +0000
+++ b/ChangeLog	Tue Apr 11 09:59:11 2006 +0000
@@ -2,6 +2,24 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-04-11 10:59:11 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-555
+
+    Summary:
+      refactored some d.has_key(k) to k in d (faster)
+    Revision:
+      moin--main--1.5--patch-555
+
+    refactored some d.has_key(k) to k in d (faster)
+    
+
+    modified files:
+     ChangeLog MoinMoin/Page.py MoinMoin/action/Despam.py
+     MoinMoin/action/links.py MoinMoin/i18n/__init__.py
+     MoinMoin/macro/OrphanedPages.py
+     MoinMoin/macro/RecentChanges.py MoinMoin/macro/WantedPages.py
+     MoinMoin/script/account/check.py
+
+
 2006-04-11 10:38:38 GMT	Alexander Schremmer <alex@alexanderweb.de.tla>	patch-554
 
     Summary:
--- a/MoinMoin/Page.py	Tue Apr 11 09:38:38 2006 +0000
+++ b/MoinMoin/Page.py	Tue Apr 11 09:59:11 2006 +0000
@@ -933,7 +933,8 @@
 
             if subscriber.isSubscribedTo(pageList):
                 lang = subscriber.language or 'en'
-                if not subscriber_list.has_key(lang): subscriber_list[lang] = []
+                if not lang in subscriber_list:
+                    subscriber_list[lang] = []
                 if return_users:
                     subscriber_list[lang].append(subscriber)
                 else:
--- a/MoinMoin/action/Despam.py	Tue Apr 11 09:38:38 2006 +0000
+++ b/MoinMoin/action/Despam.py	Tue Apr 11 09:59:11 2006 +0000
@@ -32,7 +32,7 @@
             continue
         
         editor = line.getEditor(request)
-        if not pages.has_key(line.pagename):
+        if not line.pagename in pages:
             pages[line.pagename] = 1
             editors[editor] = editors.get(editor, 0) + 1
             
@@ -75,7 +75,7 @@
         if not request.user.may.read(line.pagename):
             continue
 
-        if not pages.has_key(line.pagename):
+        if not line.pagename in pages:
             pages[line.pagename] = 1
             if line.getEditor(request) == editor:
                 line.time_tuple = request.user.getTime(wikiutil.version2timestamp(line.ed_time_usecs))
@@ -142,7 +142,7 @@
         if not request.user.may.read(line.pagename):
             continue
 
-        if not pages.has_key(line.pagename):
+        if not line.pagename in pages:
             pages[line.pagename] = 1
             if line.getEditor(request) == editor:
                 revertpages.append(line.pagename)
--- a/MoinMoin/action/links.py	Tue Apr 11 09:38:38 2006 +0000
+++ b/MoinMoin/action/links.py	Tue Apr 11 09:59:11 2006 +0000
@@ -42,7 +42,7 @@
         for link in pages[name].getPageLinks(request):
             request.write(" ")
             if mimetype == "text/html":
-                if pages.has_key(link):
+                if link in pages:
                     request.write(pages[link].link_to(request))
                 else:
                     _emit(request, link)
--- a/MoinMoin/i18n/__init__.py	Tue Apr 11 09:38:38 2006 +0000
+++ b/MoinMoin/i18n/__init__.py	Tue Apr 11 09:59:11 2006 +0000
@@ -195,13 +195,13 @@
     available = wikiLanguages()
     if not request.cfg.language_ignore_browser:
         for lang in browserLanguages(request):
-            if available.has_key(lang):
+            if lang in available:
                 if request.http_accept_language:
                     request.setHttpHeader('Vary: Accept-Language')
                 return lang
     
     # Or return the wiki default language...
-    if available.has_key(request.cfg.language_default):
+    if request.cfg.language_default in available:
         lang = request.cfg.language_default
     # If everything else fails, read the manual... or return 'en'
     else:
@@ -252,7 +252,7 @@
 
     # load texts if needed
     global _text_cache
-    if not _text_cache.has_key(lang):
+    if not lang in _text_cache:
         (texts, unformatted) = loadLanguage(request, lang)
         # XXX add error handling
         _text_cache[lang] = texts
--- a/MoinMoin/macro/OrphanedPages.py	Tue Apr 11 09:38:38 2006 +0000
+++ b/MoinMoin/macro/OrphanedPages.py	Tue Apr 11 09:59:11 2006 +0000
@@ -21,7 +21,7 @@
     for page in pages.values():
         links = page.getPageLinks(macro.request)
         for link in links:
-            if orphaned.has_key(link):
+            if link in orphaned:
                 del orphaned[link]
 
     # check for the extreme case
--- a/MoinMoin/macro/RecentChanges.py	Tue Apr 11 09:38:38 2006 +0000
+++ b/MoinMoin/macro/RecentChanges.py	Tue Apr 11 09:59:11 2006 +0000
@@ -102,7 +102,8 @@
             counters = {}
             for idx in range(len(lines)):
                 name = lines[idx].getEditor(request)
-                if not counters.has_key(name): counters[name] = []
+                if not name in counters:
+                    counters[name] = []
                 counters[name].append(idx+1)
             poslist = map(None,  counters.values(), counters.keys())
             poslist.sort()
@@ -324,7 +325,7 @@
             # new day but no changes
             this_day = day
 
-        if ignore_pages.has_key(line.pagename):
+        if line.pagename in ignore_pages:
             continue
         
         # end listing by default if user has a bookmark and we reached it
@@ -332,7 +333,7 @@
             msg = _('[Bookmark reached]')
             break
 
-        if pages.has_key(line.pagename):
+        if line.pagename in pages:
             pages[line.pagename].append(line)
         else:
             pages[line.pagename] = [line]
--- a/MoinMoin/macro/WantedPages.py	Tue Apr 11 09:38:38 2006 +0000
+++ b/MoinMoin/macro/WantedPages.py	Tue Apr 11 09:59:11 2006 +0000
@@ -45,8 +45,8 @@
         # Add links to pages which does not exists in pages dict
         links = page.getPageLinks(request)
         for link in links:
-            if not pages.has_key(link):
-                if wanted.has_key(link):
+            if not link in pages:
+                if link in wanted:
                     wanted[link][name] = 1
                 else:
                     wanted[link] = {name: 1}
--- a/MoinMoin/script/account/check.py	Tue Apr 11 09:38:38 2006 +0000
+++ b/MoinMoin/script/account/check.py	Tue Apr 11 09:59:11 2006 +0000
@@ -113,14 +113,14 @@
             self.users[uid] = u
     
             # collect name duplicates:
-            if self.names.has_key(u.name):
+            if u.name in self.names:
                 self.names[u.name].append(uid)
             else:
                 self.names[u.name] = [uid]
     
             # collect email duplicates:
             if u.email:
-                if self.emails.has_key(u.email):
+                if u.email in self.emails:
                     self.emails[u.email].append(uid)
                 else:
                     self.emails[u.email] = [uid]