Message from JavaScript discussions
May 2017
— Nope. I accidentally commented out ciritcal code, hang on
Hmm, ok, so the costs associated with maintaining the uniques list also apply to maintaining a count of all items in the set
— Hmm
— To know whether or not to increment, you need to know if a string existed before or not... a check which I removed which made it fast
— Adding the check back in, this one:
if (!list[charArray[0]][charArray.length].includes(string)) {
makes it go like 14200ms slower
— Lel
— It is a linear search... we can either use some more optimized search algorithm, maybe further refining the set's structure, or just remove it completely and not have any idea how many items are in the set
— I mean, you could count manually, of course... but you would have to do that externally because only the caller would know how many times they called add
when the string already existed in the set
— But that's not even reliable because the caller might not know that either, it would be just as costly to implement outside the class as it would be inside
— Maybe instead there can just be a length
method which sums the array lengths
—
this.length = function () {
var sum = 0;
for (var set in list) {
for (var subset in character) {
sum += subset.length;
}
}
return sum;
};
— A friend of mine reccomended trying prime divisibility instead of uniques