If you’re only loading 75 strings (sentences), just keep a pre-defined table right in your code.
It only makes sense to worry about loading from persistent-memory (device storage) when we’re talking about 100’s, 1000’s or more.
The performance hit for a table of 75 strings with a a length of say < 200 characters, will be un-detectable.
-Ed
Want to prove this to yourself? Do this:
main.lua
local function doTest() local start = system.getTimer() local myTable = require "test" local end = system.getTimer() local tmp = display.newText( 40, 40, (end - start), native.systemFont, 10 ) tmp.anchorX = 0 end -- Wait a moment after app start to allow system to settle from other launch actions -- Will give more accurate cost reading. timer.peformWithDelay( 1000, doTest )
In “test.lua”
local myTable = { -- BEGINNING OF 10 Entries "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", -- END OF last 10 } return myTable
Note: In the above sample, I only included 10 lines. You’ll need to cut-copy-past to get the number entries you want. I suggest grabbing the groups of 10 and duplicating it over again 9 more times for an even 100 lines.
When you run this, it will print the time in millisecond that it took to load the file. You’ll see it is very short. This loading is very close to the same cost your app will experience if you do this at load time.
With the newText() statement you can test this on devices to prove to yourself it is cheap.