Skip to content

Commit

Permalink
Improve _propertyContainerGet for property cont.
Browse files Browse the repository at this point in the history
The way _propertyContainerGet got a PropertySet or PropertyList
was by first trying to return as a PropertyList, then checking
the type and returning as a PropertySet if it matched. This was
inefficient because the type of a PropertyList is the same as a
PropertySet, so do that check first. Also, use isPropertySetPtr
for the test to make the code look a bit cleaner.
  • Loading branch information
r-owen committed Sep 5, 2018
1 parent 7b59ff6 commit 890fd78
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,11 @@ def _propertyContainerGet(container, name, returnStyle):
return value
return value[-1]

try:
return container.getAsPropertyListPtr(name)
except Exception:
pass
if container.typeOf(name) == container.TYPE_PropertySet:
return container.getAsPropertySetPtr(name)
if container.isPropertySetPtr(name):
try:
return container.getAsPropertyListPtr(name)
except Exception:
return container.getAsPropertySetPtr(name)
try:
return container.getAsPersistablePtr(name)
except Exception:
Expand Down

0 comments on commit 890fd78

Please sign in to comment.