From: Jeff King Date: Sat, 04 Apr 2015 14:10:26 GMT Subject: Re: [PATCH] diff-highlight: Fix broken multibyte string Message-ID: <20150404141026.GB25455@peff.net> In-Reply-To: On Fri, Apr 03, 2015 at 03:24:09PM -0700, Kyle J. McKay wrote: > >I thought that meant we could also optimize out the "map" call entirely, > >and just use the first split (with "*") to end up with a list of $COLOR > >chunks and single characters, but it does not seem to work. So maybe I > >am misreading something about what is going on. > > I think our emails crossed in flight... > > Using just the first split (with "*") produces useless empty elements which > I think ends up causing problems. I suppose you could surround it with a > grep /./ to remove them but that would defeat the point of the optimization. Yeah, the problem is the use of (). We want to keep the $COLOR delimiters, but not the empty ones. Perhaps you could do: split /($COLOR+)|/ but I didn't try it. I think what you posted is good and a lot less subtle. -Peff