Looking for ways to make code more efficient
Posted: Thu Aug 22, 2013 1:56 pm
I'm developing some basic version control system for Realflow. The following function is part of it and it steps through a Domain's export resources, looks if it is activated and then (in a different function) increments the foldernames.
Like this, it is a lot of text. I'd preferably use just one if- structure and push the constants such as EXPORT_GRID_DOMAIN_PROXY as variables through the if. Unfortunately I am not sure how to be doing that, so I am very thankful for any hints.
Code: Select all
allGFD = scene.getGridDomains()
if len(allGFD) != 0:
for dom in allGFD:
if dom.isExportResourceActive(EXPORT_GRID_DOMAIN_GFC):
exportPath = dom.getExportResourcePath(EXPORT_GRID_DOMAIN_GFC)
newPath = incrementVersionAtPath(exportPath)
if newPath != -1:
dom.setExportResourcePath(EXPORT_GRID_DOMAIN_GFC, newPath)
exportPath = ''
if dom.isExportResourceActive(EXPORT_GRID_DOMAIN_PROXY):
exportPath = dom.getExportResourcePath(EXPORT_GRID_DOMAIN_PROXY)
newPath = incrementVersionAtPath(exportPath)
if newPath != -1:
dom.setExportResourcePath(EXPORT_GRID_DOMAIN_PROXY, newPath)
exportPath = ''
#etc