Revision: 6169 Author: purodha Date: 2008-12-19 10:16:42 +0000 (Fri, 19 Dec 2008)
Log Message: ----------- Save performace avoing unneccessary 2nd replace, which always failed.
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2008-12-18 14:03:09 UTC (rev 6168) +++ trunk/pywikipedia/wikipedia.py 2008-12-19 10:16:42 UTC (rev 6169) @@ -3554,14 +3554,13 @@ firstafter = s2.find(marker) + len(marker) # Is there any text in the 'after' part that means we should keep it after? if "</noinclude>" in s2[firstafter:]: - newtext = s2[:firstafter] + s + s2[firstafter:] + newtext = s2[:firstafter].replace(marker,'') + s + s2[firstafter:] elif site.language() in site.family.categories_last: cats = getCategoryLinks(s2, site = site) s2 = removeCategoryLinks(s2.replace(marker,'').strip(), site) + separator + s newtext = replaceCategoryLinks(s2, cats, site=site) else: newtext = s2.replace(marker,'').strip() + separator + s - newtext = newtext.replace(marker,'') else: newtext = s2.replace(marker,'') return newtext @@ -3728,14 +3727,13 @@ firstafter = s2.find(marker) # Is there any text in the 'after' part that means we should keep it after? if "</noinclude>" in s2[firstafter:]: - newtext = s2[:firstafter] + s + s2[firstafter:] + newtext = s2[:firstafter].replace(marker,'') + s + s2[firstafter:] elif site.language() in site.family.categories_last: newtext = s2.replace(marker,'').strip() + separator + s else: interwiki = getLanguageLinks(s2) s2 = removeLanguageLinks(s2.replace(marker,''), site) + separator + s newtext = replaceLanguageLinks(s2, interwiki, site) - newtext = newtext.replace(marker,'') else: s2 = s2.replace(marker,'') return s2