in reply to Strange memory growth
In lvalue context,
is equivalent to$var->{$key}
so( $var //= {} )->{$key}
defined( $cg->{mainsnak}{datavalue}{value}{notexist} )
is equivalent to
defined( ( ( ( ( $cg //= {} )->{mainsnak} //= {} )->{datavalue} //= {} + )->{value} //= {} )->{notexist} )
That could potentially create a lot of new hashes.
Solution 1:
if ( $cg && $cg->{mainsnak} && $cg->{mainsnak}{datavalue} && $cg->{mainsnak}{datavalue}{value} && defined( $cg->{mainsnak}{datavalue}{value}{notexist} ) ) { ... }
Solution 2:
no autovivification; if (defined( $cg->{mainsnak}{datavalue}{value}{notexist} )) { ... }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Strange memory growth
by tinita (Parson) on Feb 14, 2018 at 18:50 UTC | |
by ikegami (Patriarch) on Feb 14, 2018 at 18:54 UTC | |
by tinita (Parson) on Feb 14, 2018 at 18:56 UTC |
In Section
Seekers of Perl Wisdom