{"thread":{"id":"36245","subject":"[PATCH] builtin/apply.c: fuzzy_matchlines:trying to fix some inefficiencies","startedAt":"2014-03-20T09:35:03Z","lastAt":"2014-03-21T06:32:15Z","messageCount":2,"participants":["George Papanikolaou","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"237151","messageId":"1395308103-16018-1-git-send-email-g3orge.app@gmail.com","threadId":"36245","inReplyTo":null,"subject":"[PATCH] builtin/apply.c: fuzzy_matchlines:trying to fix some inefficiencies","fromName":"George Papanikolaou","fromEmail":"g3orge.app@gmail.com","sentAt":"2014-03-20T09:35:03Z","receivedAt":"2014-03-20T09:35:03Z","isPatch":true,"sender":{"key":"g3orge.app@gmail.com","avatar":"https://gravatar.com/avatar/57d9756bb8e51dd138b79f2276e0bb0be2bfdc9aa60f08704de80e96d3a1c0f8?d=mp&s=160"},"body":"Hi again guys,\nI forgot to add the signed-of line to the tiny patch I sent earlier for GSOC.\nAny ideas about the changes?\nThanks...\n\nSigned-off-by: George Papanikolaou <g3orge.app@gmail.com>\n---\n builtin/apply.c | 25 +++++++++----------------\n 1 file changed, 9 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex b0d0986..df2435f 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -294,20 +294,16 @@ static int fuzzy_matchlines(const char *s1, size_t n1,\n \tconst char *last2 = s2 + n2 - 1;\n \tint result = 0;\n \n+\t/* early return if both lines are empty */\n+\tif ((s1 > last1) && (s2 > last2))\n+\t\treturn 1;\n+\n \t/* ignore line endings */\n \twhile ((*last1 == '\\r') || (*last1 == '\\n'))\n \t\tlast1--;\n \twhile ((*last2 == '\\r') || (*last2 == '\\n'))\n \t\tlast2--;\n \n-\t/* skip leading whitespace */\n-\twhile (isspace(*s1) && (s1 <= last1))\n-\t\ts1++;\n-\twhile (isspace(*s2) && (s2 <= last2))\n-\t\ts2++;\n-\t/* early return if both lines are empty */\n-\tif ((s1 > last1) && (s2 > last2))\n-\t\treturn 1;\n \twhile (!result) {\n \t\tresult = *s1++ - *s2++;\n \t\t/*\n@@ -315,18 +311,15 @@ static int fuzzy_matchlines(const char *s1, size_t n1,\n \t\t * both buffers because we don't want \"a b\" to match\n \t\t * \"ab\"\n \t\t */\n-\t\tif (isspace(*s1) && isspace(*s2)) {\n-\t\t\twhile (isspace(*s1) && s1 <= last1)\n-\t\t\t\ts1++;\n-\t\t\twhile (isspace(*s2) && s2 <= last2)\n-\t\t\t\ts2++;\n-\t\t}\n+\t\twhile (isspace(*s1) && s1 <= last1)\n+\t\t\ts1++;\n+\t\twhile (isspace(*s2) && s2 <= last2)\n+\t\t\ts2++;\n \t\t/*\n \t\t * If we reached the end on one side only,\n \t\t * lines don't match\n \t\t */\n-\t\tif (\n-\t\t    ((s2 > last2) && (s1 <= last1)) ||\n+\t\tif (((s2 > last2) && (s1 <= last1)) ||\n \t\t    ((s1 > last1) && (s2 <= last2)))\n \t\t\treturn 0;\n \t\tif ((s1 > last1) && (s2 > last2))\n-- \n1.9.0\n"},{"id":"237267","messageId":"20140321063215.GA744@sigill.intra.peff.net","threadId":"36245","inReplyTo":"1395308103-16018-1-git-send-email-g3orge.app@gmail.com","subject":"Re: [PATCH] builtin/apply.c: fuzzy_matchlines:trying to fix some inefficiencies","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-03-21T06:32:15Z","receivedAt":"2014-03-21T06:32:15Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 20, 2014 at 11:35:03AM +0200, George Papanikolaou wrote:\n\n> Hi again guys,\n> I forgot to add the signed-of line to the tiny patch I sent earlier for GSOC.\n> Any ideas about the changes?\n> Thanks...\n\nYou don't give any detail on the inefficiencies, or what specific\nbenchmark is made faster. Have you done any timings to show that there\nis a measurable improvement? If so, can you share them in the commit\nmessage?\n\n-Peff\n"}]}