some minor optimizations #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Avoid copying if the backref equals the subject tail
assigned to @geoff
We could merge the other two commits, to make the code less verbose (the compiler is probably already re-using the common subexpression).
But I don't think we need to copy or account for any terminating null byte of the subject string in order to extract backrefs, because the ovector math doesn't need it.
Oh, just occurred to me that you're trying to avoid the additional copy into workspace.
WS_Printf()is necessary inbackref()if we're copying from the middle of the string, so that the return string has a terminating null byte. But we wouldn't have to copy if a\0were already there.Damn you're stingy with workspace.
All right, but then
match()will have to copy the string with the\0as well. Think about that very carefully, because we'll be using another byte of workspace! And we might not need it, it's only any good for the "tail" case.Since we defined in varnish-cache that basically any data vmod handled is immutable (commit 2897c7e477ee70184189bed56bf74f24ebc3bb2a for example), we do not need to copy the
subjectargument to thematch()function. We can even remove the existingWS_Copy(). It does not matter if the argument lives on the workspace or not, whoever created it needs to ensure that it has at least TASK lifetime.But you are absolutely right that my patch as-is is wrong. Yes, If the
WS_Copy()stayed, we would need to also copy the null byte.I have updated the PR branch
added 31 commits
uplex-varnish:master50b007da- add variable for claritya289ca4f- constify01c613af- micro-optimize backref when the reference is the subject tailCompare with previous version
added 1 commit
a5e55971- we do not need to copy subject, it is immutable ...Compare with previous version
merged