Skip to content

Virtual cwd refactoring #15524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Aug 21, 2024

Commits should be reviewed individually.

Motivation

There are two primary motivations:

  • Prevent computing strlen() when we already know it
  • Use more appropriate types instead of int to convey meaning and intent

To achieve this, refactoring is conducted one step at a time on the various layers that interact with each other:

  • the Virtual CWD mechanism
  • the stream layer
  • the Windows I/O layer

Some other/unrelated minor refactorings are likely going to happen in some commits when I encounter some oddities.

Comment on lines -428 to +419
oldnamew = php_win32_ioutil_any_to_w(oldnamea);
oldnamew = php_win32_ioutil_conv_any_to_w(old_name_a, old_name_a_len, PHP_WIN32_CP_IGNORE_LEN_P);
Copy link
Member Author

Choose a reason for hiding this comment

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

@cmb69 as don't have a Windows machine and can't test it, is such a function call change even sensible or not?
And if yes, can I also provide a size_t pointer for the 3rd argument so that PHP_WIN32_IOUTIL_CHECK_PATH_W() doesn't need to make a call to wstrlen()?

As seemingly this changes the behaviour of some tests in ways that I don't totally understand.

@cmb69
Copy link
Member

cmb69 commented Aug 24, 2024

I'm not sure whether doing this change in zend_virtual_cwd.c now is a good idea. According to "Make it work, make it right, make it fast", we shouldn't skip the second step. That code is really contrieved, and especially tsrm_realpath_r() is a 500 line long mess. Some "extract functions" refactorings seem to be in order, although that doesn't appear to be simple; both Anatol and I tried, but gave up, a couple of years ago; that doesn't mean that it's not worth to try a fresh attempt.

@Girgias
Copy link
Member Author

Girgias commented Sep 10, 2024

I'm not sure whether doing this change in zend_virtual_cwd.c now is a good idea. According to "Make it work, make it right, make it fast", we shouldn't skip the second step. That code is really contrieved, and especially tsrm_realpath_r() is a 500 line long mess. Some "extract functions" refactorings seem to be in order, although that doesn't appear to be simple; both Anatol and I tried, but gave up, a couple of years ago; that doesn't mean that it's not worth to try a fresh attempt.

I'll chip at this when I have motivation, as passing only a char* is far from ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants