[Renderer.Picon] minor rewrite

Status
Not open for further replies.

GitHub

Moderator
[Renderer.Picon] minor rewrite

1) Use os.path.join and os.path.normpath to handle/normalise filepaths, rather than string maniplulation.
2) Use class level variables to avoid repeated recreation on every lookup.
3) Avoid mutable default keyword argument to __init__().
4) Add dedupe logic to avoid any multiple file system lookups.
4) Separate logic, i.e. findPicon() >> filesystem lookup; getPiconName() >> orchestration + dedupe; __getServiceRefPiconCandidates() >> get exact/canonical service ref candidates; __getServiceNamePiconCandidates() >> get service-name/fuzzy candidates.
5) Use generators, not functions to identify candidates.
6) Make logic completely lazy, i.e. don't process and return a list of candidates. Process each candidate individually, so as not to do unneeded work.
7) Return self.activePiconPath to None if the mount is removed.
8) Remove "if not pathExists(pngname)" from Picon.changed. Paths either exist or are an empty string. No need to touch the file system again to confirm what was proved in PiconLocator.findPicon microseconds earlier.
9) Improve logic in Picon.applySkin.
10) Attempt to improve readability of getPiconName().
11) Move config.usage.picon_lookup_priority.value to getPiconName() so it only gets accessed once per lookup, not iterated.
12) Remove unnecessary try/except blocks, and add debug to the only remaining one.

Continue reading...
 
Status
Not open for further replies.
Back
Top