Declaring local variables inside loop



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

Hi,

I do some looping like this:

FunctionInputTuple tupleWithSecond;
while (tupleStates.contains(first)) {
tupleWithSecond = FunctionInputTuple.getInstance(
tuple.getSymbol(), tupleStates);
// do some computation, replace ?first? in the list
equivalent &= equivalence.equivalent(firstValue,
secondValue);
}

Now my question is: does it matter that I declare tupleWithSecond
outside the loop? I have the impression that if I leave the first line
out and instead add ?FunctionInputTuple? before the third line, that a
new pointer space is created on the stack for each loop. Or is the
compiler smart enough to see this and optimise it away?

TIA, H.
--
Hendrik Maryns

==================
www.lieverleven.be
http://aouw.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD/FEKe+7xMGD3itQRApCNAJ0XAuO9EDzcPLMU+drVSb+7GWuRlwCeMLlI
8DO6B188P50x4WNYLLIx5MQ=
=PA5B
-----END PGP SIGNATURE-----
.



Relevant Pages

  • Re: Declaring local variables inside loop
    ... FunctionInputTuple tupleWithSecond; ... that a new pointer space is created on the stack for each loop. ... known as "premature optimization" and should be avoided ...
    (comp.lang.java.programmer)
  • Re: Declaring local variables inside loop
    ... FunctionInputTuple tupleWithSecond; ... new pointer space is created on the stack for each loop. ... known as "premature optimization" and should be avoided ...
    (comp.lang.java.programmer)
  • Re: Declaring local variables inside loop
    ... FunctionInputTuple tupleWithSecond; ... new pointer space is created on the stack for each loop. ... for variable1 and 2. ...
    (comp.lang.java.programmer)