Hi all,
I have a word game I’m porting over to iPad that reads from a word list and loads each word into a trie at startup. This was working fine in our Mac, Windows, and web builds, but I had to change the way the file was stored and loaded in order to run the app on an iPad. The new technique takes (literally) half an hour or more to load the file. I was hoping someone here might have a better solution to offer.
My original setup simply had the word list as a plain text file that sat uncompressed in the application’s package contents and was loaded via this code:
if (!File.Exists(FILENAME)) {
print("File does not exist at: " + FILENAME );
}
else {
StreamReader stream = File.OpenText(FILENAME);
while ((input = stream.ReadLine()) != null)
{
trieTable.SendMessage("AddWord", input);
}
stream.Close();
appControl.SendMessage("OnLoadWordsComplete");
}
I’ve now changed to putting the file into the Resources folder and simply assigning it via Unity editor. Then calling this code:
public TextAsset theFile;
...
using (StringReader reader = new StringReader(theFile.text))
{
while ((input = reader.ReadLine()) != null)
{
trieTable.SendMessage("AddWord", input);
}
appControl.SendMessage("OnLoadWordsComplete");
}
However, as I mentioned, this way is unbearably slow and I don’t know enough to understand why.
The word list is a newline separated list of 53,800 words and weighs in at about 350k on disk if that’s important to know.
Thanks,
~Rob