Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Obscene performance hack, it works though!

  • Loading branch information...
commit c7a52265b1dfee98e04609438acd85b1566561ea 1 parent 0138fb3
Alex Gaynor authored June 22, 2011

Showing 1 changed file with 3 additions and 1 deletion. Show diff stats Hide diff stats

  1. 4  markupsafe/_pypy_speedups.py
4  markupsafe/_pypy_speedups.py
@@ -34,7 +34,9 @@ def escape(s):
34 34
             pass
35 35
         else:
36 36
             delta += d
37  
-            repls += bool(d)
  37
+            # Obscene performance hack, d >> 2 returns 0 for 0 or 1 for 4 and 5
  38
+            # which are the only values that can be here.
  39
+            repls += d >> 2
38 40
         i += 1
39 41
         # Performance hack, can go away when PyPy's bridges are better
40 42
         # optimized

0 notes on commit c7a5226

Please sign in to comment.
Something went wrong with that request. Please try again.