From your posts it sounds like you are trying to optimize the wrong problem.
As I understand it you have a text string, consisting of a word list of 29000 words, taking approximately 240KBytes of storage.
Are you worried about download size? Then optimize the word list, and expand in memory when loaded.
Are you worried about memory footprint on the iPhone? A word list of 29000 words, assuming it takes 240KBytes of storage would expand to around 500Kbytes in RAM if stored as a single Unicode string. ECMAScript/JavaScript/Unity’s version of Javascript stores strings in Unicode format because it runs on top of the Mono framework and Mono is Unicode by default.
If you read in your 29000 word list to an array, assuming it was stored as ASCII on the file system, taking up only 240KBytes, it would take up over 900KBytes of RAM with all of the overhead. Any other storage mechanism, such as a Hash, a List or some such would push that number somewhat higher too.
If you are concerned by the amount of RAM your application is using, unless you have a metric tonne of textures and other assets, the 750KByte difference you are talking is seriously neither here nor there.
Another caveat is that even if you store your word list as a single string, the moment you start doing any sort of string splicing on it, because strings are immutable on Mono and also in JavaScript, you will begin to incur a large overhead of heap allocations, possibly far more than if you had stuffed your entire word list in to an array.
You could come up with some clever jiggery pokery that treats the word list as constant binary data block of ASCII characters by storing the strings in a .DATA section of the binary, but this is JavaScript and you ain’t going to be achieving anything magical like that in a hurry unless you write an Objective-C/C++/C/Assembly language plugin to do it for you.
Sounds like confusion over memory footprint, and heap usage, compared to data stored in the file system, that or a severe case of premature optimization.
My recommendation, without knowing anything else about your project, read each line of the text file into an array or Hash or Dictionary or whatever your preference is that enables rapid look up. When you start running out of memory, then worry about where you can optimize.
If you are concerned about download size, then optimize your word list as it is stored on the file system accordingly.
My current word game loads a 300,000 word list from disk, taking up around 250KBytes of storage, which expands in to around 6MBytes in RAM, stored in a Dictionary (Hash). When I start running out of RAM due to large graphics requirements, that’s when I’ll start optimizing my word list, until then, I’m not worried about it.
- From the person who once squeezed a hundred thousand word dictionary onto an 80KByte floppy disk for a word game on the BBC Micro Model B.