|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Yes, I know writeini will work. It's the $read that I thought was a problem with larger files... though I admit I've never tried as I don't need ini files that are that large.
|
|
|
|
DaveC
|
DaveC
|
replied to you only becuase yours was the last item mentioning /hsave -i
I think everyone should just forget the -i option, try doing a tick test on saving the file with -i compared to without it, I tried on a 10,000 item table, and OMG but does it take a long time. While a 10,000 item /HSAVE hash_table temp.txt took 16 or 32 ticks (ie: an unacuratly small time).
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Yeah, I did notice it took a little time for even that 107k test file. I guess it's really a matter of what is faster (probably his current while loop method), and whether or not he wants to consider changing how he's handling/storing the data so that it may work without dealing with this problem.
|
|
|
|
DaveC
|
DaveC
|
ok here ya go try this out.... ;Usage hdel.wilddata -bN <name> <matchtext>
;
; Deletes hashtable Items who's data matches the matchtext given.
;
; -bN : N being a number 1 or greater (default 10),
; N represents the point where a simple loop is no longer used to remove matched data items
; ie: if N is 5 and there are only 3 data matched items then a simple loop is used
; if N is 10 and there are 15 data matched items then the hsave/filter method is used.
;
alias hdel.wilddata {
;
; Pharse command line phase
;
var %breakpoint = 10
if (-* !iswm $1) {
var %hdel.wilddata.hashtable = $1
var %hdel.wilddata.matchtext = $2-
}
else {
if ($calc($mid($1,$calc($poscs($1,b) + 1))) isnum 1-) { var %breakpoint = $v1 }
var %hdel.wilddata.hashtable = $2
var %hdel.wilddata.matchtext = $3-
}
;
; Do the hdel phase
;
if (((%hdel.wilddata.hashtable != $null) && (%hdel.wilddata.matchtext != $null)) && ($hfind(%hdel.wilddata.hashtable,%hdel.wilddata.matchtext,0,w).data)) {
if ($v1 > 0) {
if ($v1 == $hget(%hdel.wilddata.hashtable,0).item) {
;
; Matchtext matched entire table
;
hdel -w %hdel.wilddata.hashtable *
}
elseif ($v1 < %breakpoint) {
;
; Simple loop method
;
while ($hfind(%hdel.wilddata.hashtable,%hdel.wilddata.matchtext,1,w).data) { hdel %hdel.wilddata.hashtable $v1 }
}
else {
;
; Hsave/filter method
;
set %hdel.wilddata.hashtable %hdel.wilddata.hashtable
hsave -ou %hdel.wilddata.hashtable hdel.wilddata.tempfile.txt
window -hn @hdel.wilddata.hidden.window
loadbuf -r @hdel.wilddata.hidden.window hdel.wilddata.tempfile.txt
hsave -oun %hdel.wilddata.hashtable hdel.wilddata.tempfile.txt
filter -fkn hdel.wilddata.tempfile.txt hdel.wilddata.filter.alias %hdel.wilddata.matchtext
window -c @hdel.wilddata.hidden.window
unset %hdel.wilddata.hashtable
}
}
}
}
alias -l hdel.wilddata.filter.alias { hdel %hdel.wilddata.hashtable $line(@hdel.wilddata.hidden.window,$calc(-1 + 2 * $1)) } it uses 3 possable methods (1) if it notices you wildcarded the whole hashtabe, it just erases the whole table (2) It uses a simple loop if there isnt many to do, default below 10 to do, or -bN and u can set that number. (3) other wise it uses a Hsave & Filter combo If anyone is interested but cant follow it i can explain.
|
|
|
|
Dr_Brom_sung_
|
Dr_Brom_sung_
|
Ok, thanks DaveC, youa re the man... The process is not called often, but when it does, it has to remove let say like 100 items or more from a 5000 items tables (more or less). This is the reason that a while loop takes ages.
I'm going to try some different methods. From what I have tested so far, using goto works 2 times faster than doing the same with a while (I have no idea why).
I'm going to try doing it with a 0 0 timer that will call a function that will remove each time the first line it finds until no lines are found, and then it stops the timer. I will then check how many ticks it takes..... :tongue:
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
Ok, thanks DaveC, youa re the man... Dave Dave, he's our man, if he can't do it, no one can! 
|
|
|
|
Dr_Brom_sung_
|
Dr_Brom_sung_
|
Ok, Using a while loop takes exactly twince as much as it takes doing the same loop with Goto which breaks when the hash table is cleaned from the data I want.
It also appears that /timer 0 0 , is as fast as using goto.
I'm going to try the idea of DaveC and see if it can speed things up a little, or if it works well with my data.
|
|
|
|
DaveC
|
DaveC
|
mahahahahaha
/me gets his Dave Flag out and starts waving it, then wonders why everyone is rolling there eyes ?¿?¿?¿?¿?¿
|
|
|
|
Dr_Brom_sung_
|
Dr_Brom_sung_
|
Dave, your method of using /filter is working amazingly fast. WOW!!!  Thanks.
|
|
|
|
|