Hi,
I am storing a large number of file paths into a hash table's keys (to
avoid duplicate paths) with well-known extensions
like .cc, .cpp, .h,.hpp. If any of the paths is a symbolic link then
the link is stored in the value field.
My questions are:
1) Is a custom data structure better than using a hash to store the
file paths?
Probably not. You seem to primarily concerned about size. Making a custom
data structure with tie or whatever is usually going to make things larger
rather than smaller. You *can* make such structures that are more memory
efficient, but to do so you have to program such things as if you were
using a lower level language (or actually using one with XS or Inline). At
which point, I'd re-evaluate whether the whole project wouldn't be better
done in such an other language.
It is possible that you would benefit from a custom data structure, but
based on the info you gave us it doesn't seem likely.
3) Does Perl allocate new memory if I were to copy the keys (paths) in
the hash table into a list or is a reference just copied?
If you put the keys into an array, they are copied. If you put them
into another hash, they are done by reference (but the overhead of the
reference is none too small). However, I doubt you should care about this.
If memory is that tight, you'd be better off rethinking the whole design
rather than making a series of fragile hacks of only marginal value.
Xho
--
--------------------
http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.