-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Small perf tweak in strlen loop #16406
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
Conversation
|
A new inspection was created. |
|
@PVince81 Is there a use case where this is heavily used? Or is this just a random optimization? |
|
Should help a bit, but the line bellow still calls strlen() :( |
|
Well, at least it doesn't call it twice. This is the loop in the encryption app that encrypts block by block. So could help for bigger files. |
|
Usually the blocks have a specific size, so another possible optimization for the second strlen would be to first see if it's a full block with |
|
sounds good |
|
Sorry, I can't fully assess the impact of this change. |
|
Refer to this link for build results (access rights to CI server needed): |
|
@PVince81 Am I correct to understand that you substitute a test checking if the first character/byte is set for a test on the length of the string? That should work here. Would such a test also improve performance at L429 ( |
|
Not sure. I just remember that we found out that "strlen" is slow compared to "isset". It is not too bad, we can also put this in for 8.2 as it's not critical. |
|
Yes, you are right that we substitute the test for length and do it with a "isset" hack. |
|
Okay, let's do it one after the other: 👍 |
|
👍 |
|
Also move |
|
@bantu You could do that, but performance will improve only marginally. I can think of only two contexts where the if-statement would evaluate to false and a strlen would be avoided by moving it into it: the case where a write is attempt on a file opened in r-mode (that should not happen), or the case where something is written in r+ mode in the middle of an unseekable encrypted stream, which is not supported by the encryption wrapper (and as far as I know r+ mode is currently not used in owncloud). |
|
stable8.1 is created -> merge |
Small perf tweak in strlen loop

See http://stackoverflow.com/questions/6955913/isset-vs-strlen-a-fast-clear-string-length-calculation
@jknockaert @th3fallen @schiesbn @DeepDiver1975