Skip to content

Conversation

@phanan
Copy link
Contributor

@phanan phanan commented Mar 17, 2015

Please correct me if I'm wrong (and close this PR), but apparently as of now the values of Request::all() and Request::input() are being re-generated everytime the methods are called:

public function all()
{
    return array_replace_recursive($this->input(), $this->files->all());
}
public function input($key = null, $default = null)
{
    $input = $this->getInputSource()->all() + $this->query->all();

Taking into account that these methods can be called multiple times (all() are internally called by only() and except() as well) and thus can be expensive, shouldn't we store those values into a "static" variable, just once, instead?

@JosephSilber
Copy link
Contributor

Be sure to repopulate those in replace.

@taylorotwell
Copy link
Member

Typically would only be called once or twice during a request, and I don't want to keep up with refreshing the "cached" variables if the request is modified, since it is mutable.

@phanan
Copy link
Contributor Author

phanan commented Mar 17, 2015

@taylorotwell Is it just me then, but I find myself calling input() quite a lot. In a big form (one of ours had like 40 fieds), this may affect performance, no? Maybe my solution is not the best, but I'd still suggest you guys find a way to cache the variables.

@taylorotwell
Copy link
Member

I would just suggest just calling it once and passing that variable around
then.

On Tue, Mar 17, 2015 at 10:11 AM, Phan An notifications@github.com wrote:

@taylorotwell https://github.com/taylorotwell Is it just me then, but I
find myself calling input() quite a lot. In a big form (one of ours had
like 40 fieds), this may affect performance, no? Maybe my solution is not
the best, but I'd still suggest you guys find a way to cache the variables.


Reply to this email directly or view it on GitHub
#8027 (comment).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants