Skip to content

Foreach argument CoW should be optimized #11775

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

Open
mvorisek opened this issue Jul 23, 2023 · 4 comments
Open

Foreach argument CoW should be optimized #11775

mvorisek opened this issue Jul 23, 2023 · 4 comments

Comments

@mvorisek
Copy link
Contributor

Description

Currently, foreach does CoW on any foreach argument ($arr) modification. This is too conservative.

https://3v4l.org/ShQmT/rfc#vgit.master

The repro shows common usecase of modifying currently iterated item/index. CoW is not needed, as the currently iterated item/index will never be iterated again.

In general, any already iterated item/key does not need CoW when unset/modified.

Also $arr append does not need CoW neither as the last element of the original $arr can be easily tracked.

@bwoebi
Copy link
Member

bwoebi commented Jul 23, 2023

So, the actual feature request is:
Reorder the FE_FREE (foreach iterated value free) to before exit branches of the foreach (as detectable by the CFG).

@iluuu1994
Copy link
Member

Your conversion is wrong. To go from microseconds to milliseconds you need to divide by 1000, not multiply by 1000.

@bwoebi
Copy link
Member

bwoebi commented Jul 24, 2023

@iluuu1994 The conversion is right - microtime(true) gives seconds.

@iluuu1994
Copy link
Member

Ah, right, sorry. Confusing name. 🙂

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

No branches or pull requests

3 participants