summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Wysocki <tomasz@pozytywnie.pl>2014-04-03 08:59:06 +0200
committerClaude Paroz <claude@2xlibre.net>2014-04-03 21:24:29 +0200
commitc28beb429107956f8bde8053936502124c964bec (patch)
tree60064586c21557305575e1b7b319806f338d04c5
parent074d3183d92cd5ed5da8f51e7048b12a96f55e0a (diff)
Refactored and commented strip_tags utility
-rw-r--r--django/utils/html.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index cf1c0c19e5..7c843cf25e 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -162,15 +162,15 @@ def _strip_once(value):
def strip_tags(value):
"""Returns the given HTML with all tags stripped."""
- while True:
- if not ('<' in value or '>' in value):
- return value
+ # Note: in typical case this loop executes _strip_once once. Loop condition
+ # is redundant, but helps to reduce number of executions of _strip_once.
+ while '<' in value and '>' in value:
new_value = _strip_once(value)
if new_value == value:
# _strip_once was not able to detect more tags
- return value
- else:
- value = new_value
+ break
+ value = new_value
+ return value
strip_tags = allow_lazy(strip_tags)