[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: out of memory
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Sat, 05 Oct 2002 23:45:57 +0200
Enrico Colombini wrote:
> I see two problems here:
> - first, newlines are inserted in the string. I can't tell them
> from those I inserted as '\n'.
> - second, if I indent my text for better reading, spaces are
> added at the beginning of each line.
To solve these problems you can:
- use <br> in stead of \n. Postprocess with gsub.
- trim away the excess spaces. Gsun is again useful there.
This is how you can do it in Lua itself:
aid = gsub(description, "%s+", " ")
description = gsub(aid, "<br>", "\n"))
It may be more performant to do this kind of postprocessing
in C. If you really wat top n,otch performance, you could customise the
Lua parser so multiple spaces are seen as a single one when parsing a
> Didn't he refer to Lua 5.0? I am still planning to use 4.0, and I already
> encountered the slow concatenation problem in another application (saving a
> large and complex table to a string took minutes).
Yes, sorry, I misunderstood. However, string concatenation
is slow in many scripting languages. I doubt VB is that much faster
than Lua in this aspect. This is a performance problem that may
need some extra attention, but has no easy solution.
"No one knows true heroes, for they speak not of their greatness." --
Björn De Meyer