Hello.
I'd like to suggest PHP introduce a new function |str_cut| to make fast cutting of a string.
If the user wants to cut a large string to a still-very-large string(say, cutting a 1KB string from a larger string),
|str_cut| would be a far more efficient alternative solution than |substr|:
str_cut($str, 1024) vs $str = substr($str, 0, 1024)
|str_cut| works by directly reseting the len value of the string.
And I have created a first-draft PR at https://github.com/php/php-src/pull/3483 , I am also going to create an RFC.
I am looking forward to your thoughts.
Zhang Junzhi
Christoph Becker just authored a StringBuilder extension which may serve as base for futher exploration at https://github.com/php/php-src/pull/3483#issuecomment-418696660
which I believe means a long-term effort to solve the issue in this respect.
I am also wondering if the StringBuilder can go into the agenda of PHP intervals. If so, is this str_cut still needed anyway?
Is StringBuilder just enough? Or both of them(StringBuilder and str_cut) are still okay to be provided?
Any thoughts?
I am happy to see either.
在2018年09月01 18時59分,"張俊芝"zjz@zjz.name寫道:
Hello.
I'd like to suggest PHP introduce a new function |str_cut| to make fast cutting of a string.
If the user wants to cut a large string to a still-very-large string(say, cutting a 1KB string from a larger string),
|str_cut| would be a far more efficient alternative solution than |substr|:
str_cut($str, 1024) vs $str = substr($str, 0, 1024)
|str_cut| works by directly reseting the len value of the string.
And I have created a first-draft PR at https://github.com/php/php-src/pull/3483 , I am also going to create an RFC.
I am looking forward to your thoughts.
Zhang Junzhi