in reply to Re: $var{el} += 1 vs $var{el} = $var{el} + 1
in thread $var{el} += 1 vs $var{el} = $var{el} + 1

Okay, so that begs a question - what is the impact on performance between:

$totalsHash{$resultHash{SomeKey}} = $resultHash{SomeKey}{AltValue};

vice

my $resultKey = $resultHash{SomeKey}; $totalsHash{$resultKey} = $resultHash{$resultKey}{AltValue};

This is assuming I am referring to the SomeKey value multiple times. I would assume the second scenario is more efficient.

Replies are listed 'Best First'.
Re^3: $var{el} += 1 vs $var{el} = $var{el} + 1
by choroba (Cardinal) on Aug 13, 2013 at 14:58 UTC
    It depends on the number of invocations. Use Benchmark to check.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^3: $var{el} += 1 vs $var{el} = $var{el} + 1 (Benchmark)
by Anonymous Monk on Aug 13, 2013 at 15:01 UTC

    Okay, so that begs a question - what is the impact on performance between:

    irrelevant :)

    Throwing memory at the problem (extra $scalar) is slightly faster than extra (double-1) hash lookups

    But you meant to type

    $someKey = $resultHash{SomeKey}; $totalsHash{ $someKey } = $$someKey{AltValue};