in reply to Re^3: "exists $hash{key}" is slower than "$hash{key}"
in thread "exists $hash{key}" is slower than "$hash{key}"
Yes, I assume the code is written this way for good historical reasons. These reasons might no longer apply or be out-weighed by other factors, but I don't know enough to be able to say if any change would be worthwhile.
The advantage of exists over checking values is tangential to the main point of the post. It's about memory usage - if one re-uses the same SV across hash values then that takes less memory than using a new SV for each hash value. It's another case where one needs a very large number of hash entries for it to make a meaningful difference, but there are times when this applies.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: "exists $hash{key}" is slower than "$hash{key}"
by LanX (Saint) on Jan 07, 2020 at 01:45 UTC | |
by swl (Prior) on Jan 07, 2020 at 03:15 UTC | |
by dave_the_m (Monsignor) on Jan 07, 2020 at 11:08 UTC | |
by swl (Prior) on Jan 09, 2020 at 03:00 UTC | |
by dave_the_m (Monsignor) on Jan 09, 2020 at 08:17 UTC | |
| |
by Anonymous Monk on Jan 09, 2020 at 09:15 UTC | |
by LanX (Saint) on Jan 07, 2020 at 16:00 UTC | |
by dave_the_m (Monsignor) on Jan 07, 2020 at 17:03 UTC |