How can I move data around quickly?

Is there a way to move every byte of data in a 200K file to a new location, like a Big Endian file to a Small Endian, and write it back out quickly?

I am using string functions now, should I be using tables? How would I?

My method is taking over several seconds, but it must be preceived as instant. Any ideas?

io.file( file, “r” ); local str1 = “”; str1 = file:read(*a); io.close( file )
local str2 = “”; local str1Len = string.len(str1)
– now the slow part –
for i=0, str1Len-1, 2 do
str2 = str2 … str1:sub(str1Len-i-1, str1-i)
end

file2 = io.open( file2, “w” );
file2:write( str2 );
io.close( file2 ) [import]uid: 47723 topic_id: 9254 reply_id: 309254[/import]

Why are you doing this? File operations in Corona are probably not the tool you want. [import]uid: 12108 topic_id: 9254 reply_id: 33758[/import]

I am trying to manipulate small portions of audio. I don’t see how to play audio, without moving it back to a file first. [import]uid: 47723 topic_id: 9254 reply_id: 33764[/import]

Never do batch concatenation in Lua as strings are immutable…instead, put every value into the row of a table, and then do a final table.concat at the end…will be instantaneous [import]uid: 6175 topic_id: 9254 reply_id: 33774[/import]

Thanks dgaedcke, that definitely improves it. [import]uid: 47723 topic_id: 9254 reply_id: 33797[/import]