1
I’m working on a web page that uses Classic ASP and I got a question, store the value of a request in a variable improves performance when compared to staying using the request("value") throughout the code?
The best is so?
if Request("valor") > 0 AND cond1 Then
...
Elseif Request("valor") < 0 AND cond2 Then
umaVar = Request("valor") + 2
End If
Or so
Dim dblValor : dblValor = Request("valor")
if dblValor > 0 AND cond1 Then
...
Elseif dblValor < 0 AND cond2 Then
umaVar = dblValor + 2
End If
Or there’s no difference?
EDIT: A motivation for doubt: When we send n data to capture with the request, among them the "value", when performing the call Request("value") I have a unique memory address to be consulted or there is something similar to a list or dictionary that the application needs to go through, Worst-case scenario in the records, every time the call is made? I don’t know how the request behavior works but I found that ASP does a search* to know if it is a Request.Form, or Request.Querystring and so on, but what about the storage of these values?
*https://msdn.microsoft.com/en-us/library/ms524948(v=vs.90). aspx
Hello Seffrin, your question is a little more or less, could you put a code to improve the understanding of who will answer? Preferably a more complete code, exemplifying your doubt.
– Asura Khan
I edited it, I think it’s clearer now.
– Seffrin
I believe that the performance will not be changed in the two forms exposed, but if we take into account the maintenance of the code create a variable to store the value is the best way; since it will be a single entry point. We assume that one day you resolve to change the name from "value" to "foo" you will have to change at all points, since if you assign to a variable you will have to change only in a single location. You should also consider that Request("value") might not be loaded with a monetary value and this would result in an error in the application.
– davidterra
I made an edition to illustrate better what generated the doubt, because I do not know how the behavior of the request works. I know he does a search to find out if it’s a Request.Form, or Request.Querystring and so on, but what about storing those values?
– Seffrin