{"thread":{"id":"27949","subject":"memrchr() implementation","startedAt":"2011-07-29T04:33:01Z","lastAt":"2011-07-29T04:47:56Z","messageCount":3,"participants":["Tay Ray Chuan","Jeff King","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"172316","messageId":"CALUzUxqNGsThcWem4mj=M3EcFF_N5GpARB+x0qx+Q1Gs76Gzig@mail.gmail.com","threadId":"27949","inReplyTo":null,"subject":"memrchr() implementation","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-07-29T04:33:01Z","receivedAt":"2011-07-29T04:33:01Z","isPatch":false,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nI'm writing a patch that requires the use of memrchr(). [1] As far as\nI know, memrchr() is non-standard.\n\nSo what's the best way to get git to use memrchr()?\n\nI was thinking of getting git to use glibc's implementation if glibc\nis present, if not, use a naive implementation included in git's code\nbase [2].\n\n--\nFootnotes:\n[1] For those interested, it's regarding content trimming to speed out\ndiffs. You can see memrchr() in use at\nhttps://github.com/rctay/git/blob/tg%2Fgsoc-diff%2Ftrim-ends/xdiff/xprepare.c#L203\n\n[2] (ISC-style license)\nhttp://www.sudo.ws/repos/sudo/file/c1ab4b940980/compat/memrchr.c\n\n-- \nCheers,\nRay Chuan\n"},{"id":"172317","messageId":"20110729044031.GA17481@sigill.intra.peff.net","threadId":"27949","inReplyTo":"CALUzUxqNGsThcWem4mj=M3EcFF_N5GpARB+x0qx+Q1Gs76Gzig@mail.gmail.com","subject":"Re: memrchr() implementation","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-07-29T04:40:31Z","receivedAt":"2011-07-29T04:40:31Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jul 29, 2011 at 12:33:01PM +0800, Tay Ray Chuan wrote:\n\n> I'm writing a patch that requires the use of memrchr(). [1] As far as\n> I know, memrchr() is non-standard.\n\nYep.\n\n> So what's the best way to get git to use memrchr()?\n> \n> I was thinking of getting git to use glibc's implementation if glibc\n> is present, if not, use a naive implementation included in git's code\n> base [2].\n\nYeah, that's our usual strategy; see how strchrnul is implemented for an\nexample.\n\nSince you are doing this for speed and not ease-of-use, I assume you are\nbenchmarking stock git versus glibc's optimized memrchr. I'd be curious\nto see a comparison to your naive implementation, too, just to\ndouble-check that your attempt at speeding up doesn't make things worse\non non-glibc platforms.\n\n-Peff\n"},{"id":"172318","messageId":"20110729044756.GA6743@elie","threadId":"27949","inReplyTo":"CALUzUxqNGsThcWem4mj=M3EcFF_N5GpARB+x0qx+Q1Gs76Gzig@mail.gmail.com","subject":"Re: memrchr() implementation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-07-29T04:47:56Z","receivedAt":"2011-07-29T04:47:56Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nTay Ray Chuan wrote:\n\n> So what's the best way to get git to use memrchr()?\n\nIn my very humble opinion: [1].\n\n> I was thinking of getting git to use glibc's implementation if glibc\n> is present, if not, use a naive implementation included in git's code\n> base [2].\n\nSounds reasonable.\n\n> [2] (ISC-style license)\n> http://www.sudo.ws/repos/sudo/file/c1ab4b940980/compat/memrchr.c\n\nFor something simple as this, I'd prefer to avoid a differently\nlicensed (even ISC-licensed) file.\n\nIt might also be worth convincing the folks at\nhttp://austingroupbugs.net/ to standardize the interface so there\ncould be optimized implementations of memrchr on more platforms over\ntime.\n\nThanks,\nJonathan\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/159081/focus=159121\n"}]}