-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🚀 Feature: "CopyBytes" and "CopyString" should only copy if "config.Immutable" is false #2285
Comments
I use the functions for non fiber purposes. |
Can you explain this more? The immutable switch should ensure that a copy is created whenever the functionality is used internally. Here the focus this time is not necessarily on performance, but rather on handling strings as you would expect from golang. |
For example the session middleware uses fiber/middleware/session/store.go Lines 97 to 100 in 61a3336
As per its documentation, Lines 495 to 496 in 61a3336
However, when the This request basically boils down to providing handlers (or, more precisely, functions with access to a request's func (c *Ctx) CopyString(s string) string {
if c.app.config.Immutable {
// Input string "s" is already a copy and safe to use
return s
}
return utils.CopyString(s)
} |
should an internal member function of the App object be used similar to |
Do you have a better name for this? When the immutable setting is on, its a copy otherwise its a reference |
Feature Description
Currently, CopyBytes and CopyString make a copy of the underlying data even if not required, i.e., when config.Immutable is set.
In order to improve performance, there should be a
app.CopyBytes
orctx.CopyBytes
which only copies the data ifconfig.Immutable
isfalse
.Additional Context (optional)
No response
Code Snippet (optional)
No response
Checklist:
The text was updated successfully, but these errors were encountered: