Federico Simoncelli has posted comments on this change.
Change subject: utils: Correct and faster list2cmdline ......................................................................
Patch Set 6: Code-Review-1
(1 comment)
Marking -1 for visibility.
http://gerrit.ovirt.org/#/c/27548/6/lib/vdsm/utils.py File lib/vdsm/utils.py:
Line 657: parts = [] Line 658: for arg in args: Line 659: if _needs_quoting(arg) or arg == '': Line 660: quoted = ("'" + s + "'" for s in arg.split("'")) Line 661: arg = r"'".join(quoted) I suggest:
def _list2cmdline(args): """...""" parts = [] for arg in args: if _needs_quoting(arg) or arg == '': arg = "'" + arg.replace("'", r"'''") + "'" parts.append(arg) return ' '.join(parts)
It's clearer, it passes the tests and profiling it seems also faster (-45%). Line 662: parts.append(arg) Line 663: return ' '.join(parts) Line 664: Line 665: