Trying to reduce memory usage

Ali Çehreli acehreli at yahoo.com
Sat Feb 13 04:19:17 UTC 2021


On 2/11/21 6:22 PM, H. S. Teoh wrote:

 > 	bool[size_t] hashes;

I would start with an even simpler solution until it's proven that there 
still is a memory issue:

import std.stdio;

void main() {
	bool[string] lines;
	foreach (line; stdin.byLine) {
		if (line !in lines) {
			stdout.writeln(line);
			lines[line.idup] = true;
		}
		// else this line already seen before; just skip it
	}
}

(Grr... Thanks for the tab characters! :p)

Ali



More information about the Digitalmars-d-learn mailing list