Skip to content

Add option to normalize path separators to Unix on Windows#9

Merged
lefessan merged 1 commit into
OCamlPro:masterfrom
ddeclerck:win_fw_slash
Jun 5, 2026
Merged

Add option to normalize path separators to Unix on Windows#9
lefessan merged 1 commit into
OCamlPro:masterfrom
ddeclerck:win_fw_slash

Conversation

@ddeclerck

Copy link
Copy Markdown
Collaborator

An attempt to add an option to normalize path separators on Windows.

@ddeclerck ddeclerck requested a review from lefessan May 28, 2026 15:29
Comment thread src/ez_file/normalizer.ml Outdated
@ddeclerck ddeclerck force-pushed the win_fw_slash branch 3 times, most recently from 3e07670 to 15860ce Compare June 4, 2026 19:53
Comment thread src/ez_file/slashifier.ml Outdated
else
if is_dir_sep dirname (l-1)
then dirname ^ filename
else dirname ^ (get_dir_separator_string ()) ^ filename

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer x ^ y ^ z -> Printf.sprintf "%s%c%s" x y z

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(the first one performs 2 string allocations, while the second one only allocates once, and is optimized by the compiler)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you implying that string allocations are not optimized?

@ddeclerck ddeclerck Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix, but note that stdlib's filename.ml does have the two concats.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread src/ez_file/slashifier.ml Outdated
Comment thread src/ez_file/slashifier.ml Outdated
Comment thread src/ez_file/slashifier.ml
@nberth

nberth commented Jun 5, 2026

Copy link
Copy Markdown

@lefessan I think this would be a good opportunity to illustrate what is the proper way to fix the workflow.yml file when it is managed by drom… There are two cases:

  • there exists a version of drom-share with a fixed workflow, so maybe only an update to the related version field?
  • such a version does not exist… how can one avoid using a custom workflow.yml.drom-tpl?

@lefessan lefessan merged commit a30451f into OCamlPro:master Jun 5, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants