Commit 63b841bc by Calen Pennington

Merge pull request #1062 from cpennington/speed-up-location-creation

Speed up Location creation returning existing locations where possible
parents 25ea91ed 0d0cb565
...@@ -169,7 +169,9 @@ class Location(_LocationBase): ...@@ -169,7 +169,9 @@ class Location(_LocationBase):
# names allow colons # names allow colons
check(list_[4], INVALID_CHARS_NAME) check(list_[4], INVALID_CHARS_NAME)
if isinstance(location, basestring): if isinstance(location, Location):
return location
elif isinstance(location, basestring):
match = URL_RE.match(location) match = URL_RE.match(location)
if match is None: if match is None:
log.debug('location is instance of %s but no URL match' % basestring) log.debug('location is instance of %s but no URL match' % basestring)
...@@ -195,8 +197,6 @@ class Location(_LocationBase): ...@@ -195,8 +197,6 @@ class Location(_LocationBase):
check_dict(kwargs) check_dict(kwargs)
return _LocationBase.__new__(_cls, **kwargs) return _LocationBase.__new__(_cls, **kwargs)
elif isinstance(location, Location):
return _LocationBase.__new__(_cls, location)
else: else:
raise InvalidLocationError(location) raise InvalidLocationError(location)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment