Is it possible to just rename a hash table without making a new one and loading the old into the new?
Nope, i made something to load it all for you though:
alias hrename {
if !$hget($1) { echo -ac Info * /hrename: ' $+ $1 $+ ' no such table. }
else {
if $hget($2) { .hfree $2 }
var %i = 1
while $hget($1,%i).item {
hadd -m $2 $ifmatch $hget($1,%i).data
inc %i
}
.hfree $1
}
}
/hrename table newtable
Thanks tidy, but I don't think it can free it fast enough. The problem is I have to delete anywhere from 1-127 lines from a hash table and write new ones items in a very short time period. It's okay but the writing is going faster than the deleting, so as its deleting its writing so only a few items may be in the table.
You may find it easier (and faster for big tables) to use the following:
alias hrename hmake $$2 | hsave -o $1 tmp | hfree $1 | hload $2 tmp | .remove tmp