{"action":"created","comment":{"url":"https://api.github.com/repos/nim-lang/Nim/pulls/comments/37742302","id":37742302,"diff_hunk":"@@ -86,40 +70,32 @@ const\n proc raiseEIO(msg: string) {.noinline, noreturn.} =\n   sysFatal(IOError, msg)\n \n-when declared(getc_unlocked):\n-  proc readLine(f: File, line: var TaintedString): bool =\n-    setLen(line.string, 0) # reuse the buffer!\n-    flockfile(f)\n-    while true:\n-      var c = getc_unlocked(f)\n-      if c < 0'i32:\n-        if line.len > 0: break\n-        else: return false\n-      if c == 10'i32: break # LF\n-      if c == 13'i32:  # CR\n-        c = getc_unlocked(f) # is the next char LF?\n-        if c != 10'i32: ungetc(c, f) # no, put the character back\n-        break\n-      add line.string, chr(int(c))\n-    result = true\n-    funlockfile(f)\n-else:\n-  proc readLine(f: File, line: var TaintedString): bool =\n-    # of course this could be optimized a bit; but IO is slow anyway...\n-    # and it was difficult to get this CORRECT with Ansi C's methods\n-    setLen(line.string, 0) # reuse the buffer!\n-    while true:\n-      var c = fgetc(f)\n-      if c < 0'i32:\n-        if line.len > 0: break\n-        else: return false\n-      if c == 10'i32: break # LF\n-      if c == 13'i32:  # CR\n-        c = fgetc(f) # is the next char LF?\n-        if c != 10'i32: ungetc(c, f) # no, put the character back\n-        break\n-      add line.string, chr(int(c))\n-    result = true\n+proc readLine(f: File, line: var TaintedString): bool =\n+  var pos = 0\n+  # Use the currently reserved space for a first try\n+  var space = cast[PGenericSeq](line.string).space","path":"lib/system/sysio.nim","position":79,"original_position":79,"commit_id":"a9b299b4ede7e96c35a6b558bbca946692d1e99d","original_commit_id":"a9b299b4ede7e96c35a6b558bbca946692d1e99d","user":{"login":"yglukhov","id":6962409,"avatar_url":"https://avatars.githubusercontent.com/u/6962409?v=3","gravatar_id":"","url":"https://api.github.com/users/yglukhov","html_url":"https://github.com/yglukhov","followers_url":"https://api.github.com/users/yglukhov/followers","following_url":"https://api.github.com/users/yglukhov/following{/other_user}","gists_url":"https://api.github.com/users/yglukhov/gists{/gist_id}","starred_url":"https://api.github.com/users/yglukhov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yglukhov/subscriptions","organizations_url":"https://api.github.com/users/yglukhov/orgs","repos_url":"https://api.github.com/users/yglukhov/repos","events_url":"https://api.github.com/users/yglukhov/events{/privacy}","received_events_url":"https://api.github.com/users/yglukhov/received_events","type":"User","site_admin":false},"body":"What does this `space` mean at the end of the line? It fails the test: `tests\\newconfig\\tfoo.nim`","created_at":"2015-08-24T11:40:22Z","updated_at":"2015-08-24T11:40:22Z","html_url":"https://github.com/nim-lang/Nim/pull/3143#discussion_r37742302","pull_request_url":"https://api.github.com/repos/nim-lang/Nim/pulls/3143","_links":{"self":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/comments/37742302"},"html":{"href":"https://github.com/nim-lang/Nim/pull/3143#discussion_r37742302"},"pull_request":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/3143"}}},"pull_request":{"url":"https://api.github.com/repos/nim-lang/Nim/pulls/3143","id":40727157,"html_url":"https://github.com/nim-lang/Nim/pull/3143","diff_url":"https://github.com/nim-lang/Nim/pull/3143.diff","patch_url":"https://github.com/nim-lang/Nim/pull/3143.patch","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/3143","number":3143,"state":"closed","locked":false,"title":"Improve performance of readLine by using fgets","user":{"login":"def-","id":2335377,"avatar_url":"https://avatars.githubusercontent.com/u/2335377?v=3","gravatar_id":"","url":"https://api.github.com/users/def-","html_url":"https://github.com/def-","followers_url":"https://api.github.com/users/def-/followers","following_url":"https://api.github.com/users/def-/following{/other_user}","gists_url":"https://api.github.com/users/def-/gists{/gist_id}","starred_url":"https://api.github.com/users/def-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/def-/subscriptions","organizations_url":"https://api.github.com/users/def-/orgs","repos_url":"https://api.github.com/users/def-/repos","events_url":"https://api.github.com/users/def-/events{/privacy}","received_events_url":"https://api.github.com/users/def-/received_events","type":"User","site_admin":false},"body":"Solves #3084. I ran the tests by @scriptum on my machine:\r\n```\r\n        Time [s]\r\nC          0.078\r\nNim New    0.084\r\nPy2        0.128\r\nPy3        0.271\r\nNim Old    0.418\r\n```\r\nProblems:\r\n- This drops compatibility with pure CR line endings of old Mac systems.\r\n- When the lines contain '\\0' chars, this currently doesn't work properly. Not sure how to fix this, since `fgets` doesn't report the number of bytes read.","created_at":"2015-07-23T22:50:54Z","updated_at":"2015-08-24T11:40:22Z","closed_at":"2015-08-21T19:30:28Z","merged_at":"2015-08-21T19:30:28Z","merge_commit_sha":"1e0092b29a4e0088bd2cb00481a1d8b9ebfa46d1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nim-lang/Nim/pulls/3143/commits","review_comments_url":"https://api.github.com/repos/nim-lang/Nim/pulls/3143/comments","review_comment_url":"https://api.github.com/repos/nim-lang/Nim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/3143/comments","statuses_url":"https://api.github.com/repos/nim-lang/Nim/statuses/a9b299b4ede7e96c35a6b558bbca946692d1e99d","head":{"label":"def-:readline-faster","ref":"readline-faster","sha":"a9b299b4ede7e96c35a6b558bbca946692d1e99d","user":{"login":"def-","id":2335377,"avatar_url":"https://avatars.githubusercontent.com/u/2335377?v=3","gravatar_id":"","url":"https://api.github.com/users/def-","html_url":"https://github.com/def-","followers_url":"https://api.github.com/users/def-/followers","following_url":"https://api.github.com/users/def-/following{/other_user}","gists_url":"https://api.github.com/users/def-/gists{/gist_id}","starred_url":"https://api.github.com/users/def-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/def-/subscriptions","organizations_url":"https://api.github.com/users/def-/orgs","repos_url":"https://api.github.com/users/def-/repos","events_url":"https://api.github.com/users/def-/events{/privacy}","received_events_url":"https://api.github.com/users/def-/received_events","type":"User","site_admin":false},"repo":{"id":21067069,"name":"Nim","full_name":"def-/Nim","owner":{"login":"def-","id":2335377,"avatar_url":"https://avatars.githubusercontent.com/u/2335377?v=3","gravatar_id":"","url":"https://api.github.com/users/def-","html_url":"https://github.com/def-","followers_url":"https://api.github.com/users/def-/followers","following_url":"https://api.github.com/users/def-/following{/other_user}","gists_url":"https://api.github.com/users/def-/gists{/gist_id}","starred_url":"https://api.github.com/users/def-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/def-/subscriptions","organizations_url":"https://api.github.com/users/def-/orgs","repos_url":"https://api.github.com/users/def-/repos","events_url":"https://api.github.com/users/def-/events{/privacy}","received_events_url":"https://api.github.com/users/def-/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/def-/Nim","description":"Nim is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nimrod's design focuses on efficiency, expressiveness, elegance (in the order of priority).","fork":true,"url":"https://api.github.com/repos/def-/Nim","forks_url":"https://api.github.com/repos/def-/Nim/forks","keys_url":"https://api.github.com/repos/def-/Nim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/def-/Nim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/def-/Nim/teams","hooks_url":"https://api.github.com/repos/def-/Nim/hooks","issue_events_url":"https://api.github.com/repos/def-/Nim/issues/events{/number}","events_url":"https://api.github.com/repos/def-/Nim/events","assignees_url":"https://api.github.com/repos/def-/Nim/assignees{/user}","branches_url":"https://api.github.com/repos/def-/Nim/branches{/branch}","tags_url":"https://api.github.com/repos/def-/Nim/tags","blobs_url":"https://api.github.com/repos/def-/Nim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/def-/Nim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/def-/Nim/git/refs{/sha}","trees_url":"https://api.github.com/repos/def-/Nim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/def-/Nim/statuses/{sha}","languages_url":"https://api.github.com/repos/def-/Nim/languages","stargazers_url":"https://api.github.com/repos/def-/Nim/stargazers","contributors_url":"https://api.github.com/repos/def-/Nim/contributors","subscribers_url":"https://api.github.com/repos/def-/Nim/subscribers","subscription_url":"https://api.github.com/repos/def-/Nim/subscription","commits_url":"https://api.github.com/repos/def-/Nim/commits{/sha}","git_commits_url":"https://api.github.com/repos/def-/Nim/git/commits{/sha}","comments_url":"https://api.github.com/repos/def-/Nim/comments{/number}","issue_comment_url":"https://api.github.com/repos/def-/Nim/issues/comments{/number}","contents_url":"https://api.github.com/repos/def-/Nim/contents/{+path}","compare_url":"https://api.github.com/repos/def-/Nim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/def-/Nim/merges","archive_url":"https://api.github.com/repos/def-/Nim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/def-/Nim/downloads","issues_url":"https://api.github.com/repos/def-/Nim/issues{/number}","pulls_url":"https://api.github.com/repos/def-/Nim/pulls{/number}","milestones_url":"https://api.github.com/repos/def-/Nim/milestones{/number}","notifications_url":"https://api.github.com/repos/def-/Nim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/def-/Nim/labels{/name}","releases_url":"https://api.github.com/repos/def-/Nim/releases{/id}","created_at":"2014-06-21T11:35:53Z","updated_at":"2015-05-04T23:13:00Z","pushed_at":"2015-08-23T21:28:36Z","git_url":"git://github.com/def-/Nim.git","ssh_url":"git@github.com:def-/Nim.git","clone_url":"https://github.com/def-/Nim.git","svn_url":"https://github.com/def-/Nim","homepage":"http://nim-lang.org/","size":42765,"stargazers_count":0,"watchers_count":0,"language":"Nimrod","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"nim-lang:devel","ref":"devel","sha":"cd42d38887d6c15be42c79b51d86e172f271d5f7","user":{"login":"nim-lang","id":603863,"avatar_url":"https://avatars.githubusercontent.com/u/603863?v=3","gravatar_id":"","url":"https://api.github.com/users/nim-lang","html_url":"https://github.com/nim-lang","followers_url":"https://api.github.com/users/nim-lang/followers","following_url":"https://api.github.com/users/nim-lang/following{/other_user}","gists_url":"https://api.github.com/users/nim-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/nim-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nim-lang/subscriptions","organizations_url":"https://api.github.com/users/nim-lang/orgs","repos_url":"https://api.github.com/users/nim-lang/repos","events_url":"https://api.github.com/users/nim-lang/events{/privacy}","received_events_url":"https://api.github.com/users/nim-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":842037,"name":"Nim","full_name":"nim-lang/Nim","owner":{"login":"nim-lang","id":603863,"avatar_url":"https://avatars.githubusercontent.com/u/603863?v=3","gravatar_id":"","url":"https://api.github.com/users/nim-lang","html_url":"https://github.com/nim-lang","followers_url":"https://api.github.com/users/nim-lang/followers","following_url":"https://api.github.com/users/nim-lang/following{/other_user}","gists_url":"https://api.github.com/users/nim-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/nim-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nim-lang/subscriptions","organizations_url":"https://api.github.com/users/nim-lang/orgs","repos_url":"https://api.github.com/users/nim-lang/repos","events_url":"https://api.github.com/users/nim-lang/events{/privacy}","received_events_url":"https://api.github.com/users/nim-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nim-lang/Nim","description":"Nim (formerly known as \"Nimrod\") is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nim's design focuses on efficiency, expressiveness, elegance (in the order of priority).","fork":false,"url":"https://api.github.com/repos/nim-lang/Nim","forks_url":"https://api.github.com/repos/nim-lang/Nim/forks","keys_url":"https://api.github.com/repos/nim-lang/Nim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nim-lang/Nim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nim-lang/Nim/teams","hooks_url":"https://api.github.com/repos/nim-lang/Nim/hooks","issue_events_url":"https://api.github.com/repos/nim-lang/Nim/issues/events{/number}","events_url":"https://api.github.com/repos/nim-lang/Nim/events","assignees_url":"https://api.github.com/repos/nim-lang/Nim/assignees{/user}","branches_url":"https://api.github.com/repos/nim-lang/Nim/branches{/branch}","tags_url":"https://api.github.com/repos/nim-lang/Nim/tags","blobs_url":"https://api.github.com/repos/nim-lang/Nim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nim-lang/Nim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nim-lang/Nim/git/refs{/sha}","trees_url":"https://api.github.com/repos/nim-lang/Nim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nim-lang/Nim/statuses/{sha}","languages_url":"https://api.github.com/repos/nim-lang/Nim/languages","stargazers_url":"https://api.github.com/repos/nim-lang/Nim/stargazers","contributors_url":"https://api.github.com/repos/nim-lang/Nim/contributors","subscribers_url":"https://api.github.com/repos/nim-lang/Nim/subscribers","subscription_url":"https://api.github.com/repos/nim-lang/Nim/subscription","commits_url":"https://api.github.com/repos/nim-lang/Nim/commits{/sha}","git_commits_url":"https://api.github.com/repos/nim-lang/Nim/git/commits{/sha}","comments_url":"https://api.github.com/repos/nim-lang/Nim/comments{/number}","issue_comment_url":"https://api.github.com/repos/nim-lang/Nim/issues/comments{/number}","contents_url":"https://api.github.com/repos/nim-lang/Nim/contents/{+path}","compare_url":"https://api.github.com/repos/nim-lang/Nim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nim-lang/Nim/merges","archive_url":"https://api.github.com/repos/nim-lang/Nim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nim-lang/Nim/downloads","issues_url":"https://api.github.com/repos/nim-lang/Nim/issues{/number}","pulls_url":"https://api.github.com/repos/nim-lang/Nim/pulls{/number}","milestones_url":"https://api.github.com/repos/nim-lang/Nim/milestones{/number}","notifications_url":"https://api.github.com/repos/nim-lang/Nim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nim-lang/Nim/labels{/name}","releases_url":"https://api.github.com/repos/nim-lang/Nim/releases{/id}","created_at":"2010-08-16T20:38:58Z","updated_at":"2015-08-24T05:44:03Z","pushed_at":"2015-08-23T22:54:27Z","git_url":"git://github.com/nim-lang/Nim.git","ssh_url":"git@github.com:nim-lang/Nim.git","clone_url":"https://github.com/nim-lang/Nim.git","svn_url":"https://github.com/nim-lang/Nim","homepage":"http://nim-lang.org/","size":354075,"stargazers_count":2269,"watchers_count":2269,"language":"Nimrod","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":299,"mirror_url":null,"open_issues_count":582,"forks":299,"open_issues":582,"watchers":2269,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/3143"},"html":{"href":"https://github.com/nim-lang/Nim/pull/3143"},"issue":{"href":"https://api.github.com/repos/nim-lang/Nim/issues/3143"},"comments":{"href":"https://api.github.com/repos/nim-lang/Nim/issues/3143/comments"},"review_comments":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/3143/comments"},"review_comment":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/3143/commits"},"statuses":{"href":"https://api.github.com/repos/nim-lang/Nim/statuses/a9b299b4ede7e96c35a6b558bbca946692d1e99d"}}}}