Skip to content

Commit 525b0cd

Browse files
committed
Use re.match() to simplify Version.identifier_friendly
re_sha is only used once so the overhead of calling re.compile() implicitly is minimal which means we can simplify the code by using re.match() instead.
1 parent 2215dfd commit 525b0cd

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

readthedocs/builds/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ def delete(self, *args, **kwargs):
164164
@property
165165
def identifier_friendly(self):
166166
'''Return display friendly identifier'''
167-
re_sha = re.compile(r'^[0-9a-f]{40}$', re.I)
168-
if re_sha.match(self.identifier):
167+
if re.match(r'^[0-9a-f]{40}$', self.identifier, re.I):
169168
return self.identifier[:8]
170169
return self.identifier
171170

0 commit comments

Comments
 (0)