2 ms·
That roughly corresponds to the following C-like pseudocode: for (i = 0; i < argc && (arg = argv[i]).startswith("--"); ++i) if (sep = arg.find("=")
by lifthrasiir 7y ago
That roughly corresponds to the following C-like pseudocode:
for (i = 0; i < argc && (arg = argv[i]).startswith("--"); ++i)
if (sep = arg.find("=")) opts[arg[..sep]] = arg[sep+1..]; else opts[arg] = "x";
It might be too much for one line, but it doesn't seem to be super complicated either. In fact that line is (as of now, commit 0006330) only the second longest in that file.
- deleted 7y ago[deleted]
- oblio 7y agoI'd definitely refactor your C-like pseudocode to multiple lines :-D
- lifthrasiir 7y agoOf course, in real projects I don't write such codes. But that's not because it is harder to read, but because it is harder to alter; say, if you have another condition for say `-v` vs. `--verbose` then you would have to reformat it to multiple lines. The meaning of the quoted line is not hard to figure out if you know a bit of bash, and that's all I would expect from a showcase.
- kubanczyk 7y agoOf course what you fight for is readability and only readability. Especially in large projects. There will be literally 10 man-hours spent on reading this for each 1 man-hour of reading-followed-by-altering-it.