[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ‘new text-spanner’ development
From: |
David Kastrup |
Subject: |
Re: ‘new text-spanner’ development |
Date: |
Thu, 24 Sep 2015 16:53:29 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
David Nalesnik <address@hidden> writes:
> Hi,
>
> On Wed, Sep 23, 2015 at 7:35 AM, David Nalesnik <address@hidden>
> wrote:
>
>>
>>
>> On Wed, Sep 23, 2015 at 6:54 AM, David Kastrup <address@hidden> wrote:
>>
>> the following open-coded loop is
>>> both opaque and inefficient (namely O(n^2) as _appending_ to a list is
>>> an O(n) operation):
>>>
>>>
>> OK, thanks! Will update accordingly.
>>
>>
> I removed that idiom from the code, so it should be somewhat more efficient.
Well, the efficiency is not likely a concern for most use cases here.
But of course, once a text spanner like that is available, one can
indeed let it accompany a whole piece with hundreds or thousands of
elements. And then it may become quite noticeable.
While O(n^2) code is sort of an automatic trigger for programmer
neuroses for me, I was more concerned about the readability. Use of
"map" makes the relation between input and output more transparent.
--
David Kastrup