Re: How to improve performance when reading text files?



szabolcs.szucs wrote:
Append is the key. Because of you collecting lines into a list which
is a simply linked one
(afaik) when appending to the end, you have to iterate over the list
every time. This makes the solution O(n^2).. A somewhat better
solution is to (cons line retval) and return (reverse retval) which
makes stuff linear (O(n)), although consider using arrays.
True.
Even better (faster) is returning (nreverse retval).
.



Relevant Pages

  • Re: How to improve performance when reading text files?
    ... when appending to the end, you have to iterate over the list ... Even better is returning (nreverse retval). ...
    (comp.lang.lisp)
  • Re: Newbie: Save, retrieve user choices?
    ... I have the Learning Edition (I ... I obtained this legally (AFAIK) from another ... If I were writing a Word macro, I would just iterate through the lines ... a Lines or Paragraphs collection available, ...
    (microsoft.public.vb.general.discussion)
  • Re: Deriving the ordinal position from a field name
    ... position number of a field by specifying the name of the field. ... AFAIK, you would have to iterate over the field collection, checking to see ... Stephen Howe ...
    (microsoft.public.data.ado)
  • Re: Making ITERATE available in all packages in CLISP?
    ... Zach KS writes: ... If there are people here that care about Iterate, they might speak up because there wasn't much discussion on the mailing list. ... (iterate:defsynonym:appending iterate:appending) ... that only exports ITERATE? ...
    (comp.lang.lisp)