www.digitalmars.com         C & C++   DMDScript  

D - rehash unstability - data.txt

reply kw <kw_member pathlink.com> writes:
import stream;

void main()
{
int[char[]] esdom;
File f = new File("data.txt");

while(!f.eof())  esdom[f.readLine()] = 0;
f.close();
esdom.rehash;
}

DMD 0.71
With the attached data.txt file, rehash never ends (or takes a looong time).  If
you remove/change the last line of data.txt, rehash does its stuff in a blink.


begin 0644 data.txt

M>F-Y8F5R<V5A<F-H+F-O;0T*860P+F=A;65S=V5B+F-O;0T*860P+FAA>6YE









M,RYE<F%S97)C87-H+F-O;0T*860P,RYE>F-Y8F5R<V5A<F-H+F-O;0T*860P




















M,#DN
M+F-O;0T*860Q+F%D;F5T=V]R:RYC;VTN8G(-"F%D,2YA9'-O;'5T:6]N+F1E


M8FQE8VQI8VLN8F4-"F%D,2YD;W5B;&5C;&EC:RYC;VT-"F%D,2YD;W5B;&5C
M;&EC:RYN970-"F%D,2YE;65D:6%T92YD:PT*860Q+F5R87-E<F-A<V N8V]M

M,2YG86UE>F]N92YD90T*860Q+FAP9RYC;VTN8G(-"F%D,2YH<&<N:6<N8V]M


M<&%M961I82YC;VTN874-"F%D,2YP87EC;W5N="YC;VT-"F%D,2YP965L+F-O

M;W)E=&DN:70-"F%D,2YT87)G971G<F%P:"YC;VT-"F%D,2YT<F%F9FEC>"YC

M,"YD;W5B;&5C;&EC:RYB90T*860Q,"YE<F%S97)C87-H+F-O;0T*860Q,"YE
M>F-Y8F5R<V5A<F-H+F-O;0T*860Q,"YF;V-A;&EN:RYC;VT-"F%D,3`N:'!G

M,"YP87EC;W5N="YC;VT-"F%D,3`N<&]P=7!A9"YN970-"F%D,3`P+F5R87-E






M>6)E<G-E87)C:"YC;VT-"F%D,3`R+FAP9RYC;VTN8G(-"F%D,3`R+FAP9RYI








M8G(-"F%D,3`U+FAP9RYI9RYC;VTN8G(-"F%D,3`U+G!A>6-O=6YT+F-O;0T*







M"F%D,3`X+FAP9RYC;VTN8G(-"F%D,3`X+FAP9RYI9RYC;VTN8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R+F)I;&QB;V%R

M9&]U8FQE8VQI8VLN8F4-"F%D,BYD;W5B;&5C;&EC:RYC;VT-"F%D,BYD;W5B
M;&5C;&EC:RYN970-"F%D,BYE<F%S97)C87-H+F-O;0T*860R+F5Z8WEB97)S

?860R+FAP9RYI9RYC;VTN8G(-"F%D,BYL8F4N<G4-"C(N
`
end
Sep 08 2003
next sibling parent reply "Charles Sanders" <sanders-consulting comcast.net> writes:
Is this on linux ?  I had a bug that when reading in a file using eof(), if
the file did not end in a new line it would seg fault, or just hang forever.

Charles

"kw" <kw_member pathlink.com> wrote in message
news:bjid97$169c$1 digitaldaemon.com...
 import stream;

 void main()
 {
 int[char[]] esdom;
 File f = new File("data.txt");

 while(!f.eof())  esdom[f.readLine()] = 0;
 f.close();
 esdom.rehash;
 }

 DMD 0.71
 With the attached data.txt file, rehash never ends (or takes a looong
time). If
 you remove/change the last line of data.txt, rehash does its stuff in a
blink.

Sep 08 2003
parent kw <kw_member pathlink.com> writes:
In article <bjikil$1h4t$1 digitaldaemon.com>, Charles Sanders says...
Is this on linux ?  I had a bug that when reading in a file using eof(), if
the file did not end in a new line it would seg fault, or just hang forever.
No, Windows. It also can be reproduced without using files.
Sep 08 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
I have this fixed now. -Walter
Sep 13 2003