Add option to normalize path separators to Unix on Windows#9
Conversation
3e07670 to
15860ce
Compare
| else | ||
| if is_dir_sep dirname (l-1) | ||
| then dirname ^ filename | ||
| else dirname ^ (get_dir_separator_string ()) ^ filename |
There was a problem hiding this comment.
I would prefer x ^ y ^ z -> Printf.sprintf "%s%c%s" x y z
There was a problem hiding this comment.
(the first one performs 2 string allocations, while the second one only allocates once, and is optimized by the compiler)
There was a problem hiding this comment.
Are you implying that string allocations are not optimized?
There was a problem hiding this comment.
Will fix, but note that stdlib's filename.ml does have the two concats.
There was a problem hiding this comment.
Are you implying that string allocations are not optimized?
I am pretty sure they are not. if we had experts in optimizations in the OCaml compiler, we could ask them...
Note that the compiler will combine several allocations in one if they happen without anything between them, but in this case, they are done in external functions, so the compiler cannot combine them (and there is no pattern, at least the last time I checked 20 years ago, to detect multiple string concats and optimize them)
|
@lefessan I think this would be a good opportunity to illustrate what is the proper way to fix the
|
An attempt to add an option to normalize path separators on Windows.