Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Reduce RAM required

by hippo (Bishop)
on Jan 08, 2019 at 10:36 UTC ( [id://1228194]=note: print w/replies, xml ) Need Help??


in reply to Reduce RAM required

There is very little scoping used here. The @IDsLens array is very large and is apparently only used to construct the hash. Why? I can't see that this is necessary but even if you think that it is, the scope should be limited to this construction phase.

I would be inclined to refactor the code into subs. It would make the purpose clearer, help to enforce some scoping and allow for better profiling.

While it probably won't affect the RAM footprint, your code is verbose to the extent that it becomes harder to read, not easier. In the construction loop, for example you have this:

if ($_ =~ m/\>/) { # ... } elsif ($_ !~ m/\>/) { # ... }

which could equally be written as

if (/>/) { # ... } else { # ... }

While the way you have written it will work, it takes longer and more effort for the programmer to read and parse (and wonder why there is an elsif in there).

I hope these tips are of some use to you.

Replies are listed 'Best First'.
Re^2: Reduce RAM required
by onlyIDleft (Scribe) on Jan 09, 2019 at 16:15 UTC

    Thank you for those suggestions.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228194]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found