]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
gen-sitemap: minor optimization
authorOleg Broytman <phd@phdru.name>
Sun, 15 Mar 2015 22:54:58 +0000 (01:54 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 23 Dec 2015 15:54:10 +0000 (18:54 +0300)
Append the leaf to current_subtree once after if.

gen-sitemap.py

index 1a78a7fb84b8fda32dbfdd1a3712ad8aa922668c..b6ab57d8be254160c17af11d82e1fe3282e26498 100755 (executable)
@@ -38,13 +38,11 @@ for dirpath, dirs, files in sorted(os.walk(fullpath)):
             current_subtree = tree[1]
             for i in range(level):
                 current_subtree = current_subtree[-1][1]
-            current_subtree.append((parts[-1], []))
-        elif level == save_level:
-            current_subtree.append((parts[-1], []))
         elif level > save_level:
             assert level - save_level == 1
             current_subtree = current_subtree[-1][1]
-            current_subtree.append((parts[-1], []))
+        #else: # level == save_level:
+        current_subtree.append((parts[-1], []))
         save_level = level
     except StopIteration:
         pass