[darcs-devel] [issue1450] Increase laziness of countable nouns (englishNum).

Trent Buck bugs at darcs.net
Thu Apr 23 01:37:09 UTC 2009


New submission from Trent Buck <trentbuck at gmail.com>:

I saw this patch come in recently:

    [Refactor English patch/patches in darcs get.
    Eric Kow <kowey at darcs.net>**20090413180400
     Ignore-this: 3762aa5af1a16467a2a1ce00db3fb946
    ] hunk ./src/Darcs/Commands/Get.lhs 71
    +import English ( englishNum, Noun(..) )
    hunk ./src/Darcs/Commands/Get.lhs 269
    -                   (patch_or_patches $ lengthFL ps)
    +                   (englishNum (lengthFL ps) (Noun "patch") "")
    hunk ./src/Darcs/Commands/Get.lhs 278
    -patch_or_patches :: Int -> String
    -patch_or_patches 1 = "patch."
    -patch_or_patches _ = "patches."

English countable nouns need to know if the length is exactly one --
once it gets to 2, it can stop traversing the list.

But because `englishNum` takes a number instead of a traversible
sequence (e.g. a list or a lazy bytestring), I guess that most usages
currently traverse the entire sequence.  I don't know if it's an issue
for the above example, but it wouldn't surprise me if there are cases
where this results in really slow O(n) performance instead of O(1).

----------
messages: 7746
nosy: dmitry.kurochkin, kowey, simon, thorkilnaur, twb
status: unread
title: Increase laziness of countable nouns (englishNum).

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/issue1450>
__________________________________


More information about the darcs-devel mailing list