zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: Incorrect sorting of Polish characters
Date: Wed, 20 Jul 2016 09:35:15 +0100	[thread overview]
Message-ID: <20160720093515.07cedcdc@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <160719220508.ZM10438@torch.brasslantern.com>

On Tue, 19 Jul 2016 22:05:08 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Jul 18, 11:17am, Peter Stephenson wrote:
> }
> } Adding an umetafied entry to the glob match that only gets used for
> } sorting seems to do the trick.  I think an additional single pass
> } through the array of matches isn't a big deal.
> 
> Hm.  On a glob of 16794 files it's about 4% slower over 10 trials with
> the extra pass over the array of matches.  I don't suppose there's some
> way to store the original file name at the time metafication is applied
> rather than metafying and then unmetafying again?

It already works like that, and it only copies and unmetafies if there's
a Meta character.

It might be possible to squeeze this code somewhere else at the expense
of clarity and likelihood of bugs.  There are about four places where
the name is set which could be turned into a function.

Daniel pointed out strchr() would be neater.

pws

diff --git a/Src/glob.c b/Src/glob.c
index 146b4db..850405f 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1922,13 +1922,7 @@ zglob(LinkList list, LinkNode np, int nountok)
 	 */
 	for (gmptr = matchbuf; gmptr < matchptr; gmptr++)
 	{
-	    char *nptr;
-	    for (nptr = gmptr->name; *nptr; nptr++)
-	    {
-		if (*nptr == Meta)
-		    break;
-	    }
-	    if (*nptr == Meta)
+	    if (strchr(gmptr->name, Meta))
 	    {
 		int dummy;
 		gmptr->uname = dupstring(gmptr->name);


  reply	other threads:[~2016-07-20  8:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-16 17:17 Michał Bartoszkiewicz
2016-07-16 20:07 ` Bart Schaefer
2016-07-18  9:33   ` Peter Stephenson
2016-07-18 10:17     ` Peter Stephenson
2016-07-20  5:05       ` Bart Schaefer
2016-07-20  8:35         ` Peter Stephenson [this message]
2016-07-22  0:38           ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160720093515.07cedcdc@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).