Commits

Anonymous committed 195dbb4

Only compile the SHA1 regex once per process

Comments (0)

Files changed (1)

registration/models.py

 from django.contrib.sites.models import Site
 from django.conf import settings
 
+SHA1_RE = re.compile('^[a-f0-9]{40}$')
 
 class RegistrationManager(models.Manager):
     """
         # Make sure the key we're trying conforms to the pattern of a
         # SHA1 hash; if it doesn't, no point even trying to look it up
         # in the DB.
-        if re.match('[a-f0-9]{40}', activation_key):
+        if SHA1_RE.search(activation_key):
             try:
                 user_profile = self.get(activation_key=activation_key)
             except self.model.DoesNotExist:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.