{"action":"created","comment":{"url":"https://api.github.com/repos/effuse/profuse/pulls/comments/70968849","id":70968849,"diff_hunk":"@@ -1035,40 +1035,41 @@ module Out = struct\n     let struct_size = hdrsz\n     let size name = hdrsz + 8 * (((String.length name) + 7) / 8)\n \n-    let of_list ~host listing offset read_size req =\n-      let phost = host.Host.dirent.Dirent.Host.file_kind in\n-      let emit = ref false in\n-      let count = ref 0 in\n-      let listing = List.fold_left (fun acc ((off,_,name,_) as ent) ->\n-        if offset <> 0 && not !emit then (* TODO: fixme this is gross *)\n-          if off = offset\n-          then (emit := true; acc)\n-          else acc\n-        else\n-          let next_total = !count + (size name) in\n-          if next_total > read_size\n-          then acc\n-          else begin\n-            count := next_total;\n-            ent::acc\n-          end\n-      ) [] listing in\n-      let count = !count in\n-      let pkt = Hdr.packet ~count req in\n-      let buf = CArray.start pkt in\n-      let ep = List.fold_left (fun p (off,ino,name,typ) ->\n-        let sz = size name in\n-        let dirent = !@ (coerce (ptr char) (ptr T.t) p) in\n-        let typ = Dirent.File_kind.(to_code ~host:phost typ) in\n+    let filter_listing listing offset read_limit =\n+      let rec loop acc ~read ~emit = function\n+        | [] ->\n+          listing, read\n+        | (_,_,name,_) :: l when read + size name > read_limit ->\n+          listing, read\n+        | ((_,_,name,_) as ent)::l when offset = 0 || emit ->\n+          loop (ent :: acc) ~read:(read + size name) ~emit l\n+        | (off,_,_,_) :: l ->\n+          loop acc ~read ~emit:(off = offset) l\n+      in loop [] ~read:0 ~emit:false listing      \n+\n+    let store ~ino ~off ~name ~typ dirent =\n+      let p = coerce (ptr T.t) (ptr char) (addr dirent) in\n+      begin\n         setf dirent T.ino     (UInt64.of_int64 ino);\n         setf dirent T.off     (UInt64.of_int off);\n         setf dirent T.namelen (UInt32.of_int (String.length name));\n         setf dirent T.typ     (UInt32.of_int (int_of_char typ));\n         let sp = ref (p +@ hdrsz) in\n         (* TODO: better copy *)\n-        String.iter (fun c -> !sp <-@ c; sp := !sp +@ 1) name;\n+        String.iter (fun c -> !sp <-@ c; sp := !sp +@ 1) name","path":"lib/profuse_7_23.ml","position":51,"original_position":51,"commit_id":"1c416465574844077f0607186b69fb395b7914ad","original_commit_id":"1c416465574844077f0607186b69fb395b7914ad","user":{"login":"yallop","id":1736496,"avatar_url":"https://avatars.githubusercontent.com/u/1736496?v=3","gravatar_id":"","url":"https://api.github.com/users/yallop","html_url":"https://github.com/yallop","followers_url":"https://api.github.com/users/yallop/followers","following_url":"https://api.github.com/users/yallop/following{/other_user}","gists_url":"https://api.github.com/users/yallop/gists{/gist_id}","starred_url":"https://api.github.com/users/yallop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yallop/subscriptions","organizations_url":"https://api.github.com/users/yallop/orgs","repos_url":"https://api.github.com/users/yallop/repos","events_url":"https://api.github.com/users/yallop/events{/privacy}","received_events_url":"https://api.github.com/users/yallop/received_events","type":"User","site_admin":false},"body":"No, but there's [this](https://github.com/yallop/ocaml-memcpy).","created_at":"2016-07-15T13:03:07Z","updated_at":"2016-07-15T13:03:07Z","html_url":"https://github.com/effuse/profuse/pull/58#discussion_r70968849","pull_request_url":"https://api.github.com/repos/effuse/profuse/pulls/58","_links":{"self":{"href":"https://api.github.com/repos/effuse/profuse/pulls/comments/70968849"},"html":{"href":"https://github.com/effuse/profuse/pull/58#discussion_r70968849"},"pull_request":{"href":"https://api.github.com/repos/effuse/profuse/pulls/58"}}},"pull_request":{"url":"https://api.github.com/repos/effuse/profuse/pulls/58","id":77598585,"html_url":"https://github.com/effuse/profuse/pull/58","diff_url":"https://github.com/effuse/profuse/pull/58.diff","patch_url":"https://github.com/effuse/profuse/pull/58.patch","issue_url":"https://api.github.com/repos/effuse/profuse/issues/58","number":58,"state":"open","locked":false,"title":"Refactor Dirent.of_list","user":{"login":"yallop","id":1736496,"avatar_url":"https://avatars.githubusercontent.com/u/1736496?v=3","gravatar_id":"","url":"https://api.github.com/users/yallop","html_url":"https://github.com/yallop","followers_url":"https://api.github.com/users/yallop/followers","following_url":"https://api.github.com/users/yallop/following{/other_user}","gists_url":"https://api.github.com/users/yallop/gists{/gist_id}","starred_url":"https://api.github.com/users/yallop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yallop/subscriptions","organizations_url":"https://api.github.com/users/yallop/orgs","repos_url":"https://api.github.com/users/yallop/repos","events_url":"https://api.github.com/users/yallop/events{/privacy}","received_events_url":"https://api.github.com/users/yallop/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-15T11:00:25Z","updated_at":"2016-07-15T13:03:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"56b19d794c65b00f0c21b861b43bf1f4ddd246ac","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/effuse/profuse/pulls/58/commits","review_comments_url":"https://api.github.com/repos/effuse/profuse/pulls/58/comments","review_comment_url":"https://api.github.com/repos/effuse/profuse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/effuse/profuse/issues/58/comments","statuses_url":"https://api.github.com/repos/effuse/profuse/statuses/1c416465574844077f0607186b69fb395b7914ad","head":{"label":"yallop:dirent-refactor-master","ref":"dirent-refactor-master","sha":"1c416465574844077f0607186b69fb395b7914ad","user":{"login":"yallop","id":1736496,"avatar_url":"https://avatars.githubusercontent.com/u/1736496?v=3","gravatar_id":"","url":"https://api.github.com/users/yallop","html_url":"https://github.com/yallop","followers_url":"https://api.github.com/users/yallop/followers","following_url":"https://api.github.com/users/yallop/following{/other_user}","gists_url":"https://api.github.com/users/yallop/gists{/gist_id}","starred_url":"https://api.github.com/users/yallop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yallop/subscriptions","organizations_url":"https://api.github.com/users/yallop/orgs","repos_url":"https://api.github.com/users/yallop/repos","events_url":"https://api.github.com/users/yallop/events{/privacy}","received_events_url":"https://api.github.com/users/yallop/received_events","type":"User","site_admin":false},"repo":{"id":48549309,"name":"profuse","full_name":"yallop/profuse","owner":{"login":"yallop","id":1736496,"avatar_url":"https://avatars.githubusercontent.com/u/1736496?v=3","gravatar_id":"","url":"https://api.github.com/users/yallop","html_url":"https://github.com/yallop","followers_url":"https://api.github.com/users/yallop/followers","following_url":"https://api.github.com/users/yallop/following{/other_user}","gists_url":"https://api.github.com/users/yallop/gists{/gist_id}","starred_url":"https://api.github.com/users/yallop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yallop/subscriptions","organizations_url":"https://api.github.com/users/yallop/orgs","repos_url":"https://api.github.com/users/yallop/repos","events_url":"https://api.github.com/users/yallop/events{/privacy}","received_events_url":"https://api.github.com/users/yallop/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yallop/profuse","description":"An OCaml implementation of the FUSE protocol version 7.8","fork":true,"url":"https://api.github.com/repos/yallop/profuse","forks_url":"https://api.github.com/repos/yallop/profuse/forks","keys_url":"https://api.github.com/repos/yallop/profuse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yallop/profuse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yallop/profuse/teams","hooks_url":"https://api.github.com/repos/yallop/profuse/hooks","issue_events_url":"https://api.github.com/repos/yallop/profuse/issues/events{/number}","events_url":"https://api.github.com/repos/yallop/profuse/events","assignees_url":"https://api.github.com/repos/yallop/profuse/assignees{/user}","branches_url":"https://api.github.com/repos/yallop/profuse/branches{/branch}","tags_url":"https://api.github.com/repos/yallop/profuse/tags","blobs_url":"https://api.github.com/repos/yallop/profuse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yallop/profuse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yallop/profuse/git/refs{/sha}","trees_url":"https://api.github.com/repos/yallop/profuse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yallop/profuse/statuses/{sha}","languages_url":"https://api.github.com/repos/yallop/profuse/languages","stargazers_url":"https://api.github.com/repos/yallop/profuse/stargazers","contributors_url":"https://api.github.com/repos/yallop/profuse/contributors","subscribers_url":"https://api.github.com/repos/yallop/profuse/subscribers","subscription_url":"https://api.github.com/repos/yallop/profuse/subscription","commits_url":"https://api.github.com/repos/yallop/profuse/commits{/sha}","git_commits_url":"https://api.github.com/repos/yallop/profuse/git/commits{/sha}","comments_url":"https://api.github.com/repos/yallop/profuse/comments{/number}","issue_comment_url":"https://api.github.com/repos/yallop/profuse/issues/comments{/number}","contents_url":"https://api.github.com/repos/yallop/profuse/contents/{+path}","compare_url":"https://api.github.com/repos/yallop/profuse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yallop/profuse/merges","archive_url":"https://api.github.com/repos/yallop/profuse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yallop/profuse/downloads","issues_url":"https://api.github.com/repos/yallop/profuse/issues{/number}","pulls_url":"https://api.github.com/repos/yallop/profuse/pulls{/number}","milestones_url":"https://api.github.com/repos/yallop/profuse/milestones{/number}","notifications_url":"https://api.github.com/repos/yallop/profuse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yallop/profuse/labels{/name}","releases_url":"https://api.github.com/repos/yallop/profuse/releases{/id}","deployments_url":"https://api.github.com/repos/yallop/profuse/deployments","created_at":"2015-12-24T16:07:48Z","updated_at":"2016-04-22T12:49:46Z","pushed_at":"2016-07-15T12:35:15Z","git_url":"git://github.com/yallop/profuse.git","ssh_url":"git@github.com:yallop/profuse.git","clone_url":"https://github.com/yallop/profuse.git","svn_url":"https://github.com/yallop/profuse","homepage":null,"size":430,"stargazers_count":0,"watchers_count":0,"language":"OCaml","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":"master"}},"base":{"label":"effuse:master","ref":"master","sha":"59939f32f967576946a5fe9bd77d4907abfebbc4","user":{"login":"effuse","id":19324163,"avatar_url":"https://avatars.githubusercontent.com/u/19324163?v=3","gravatar_id":"","url":"https://api.github.com/users/effuse","html_url":"https://github.com/effuse","followers_url":"https://api.github.com/users/effuse/followers","following_url":"https://api.github.com/users/effuse/following{/other_user}","gists_url":"https://api.github.com/users/effuse/gists{/gist_id}","starred_url":"https://api.github.com/users/effuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/effuse/subscriptions","organizations_url":"https://api.github.com/users/effuse/orgs","repos_url":"https://api.github.com/users/effuse/repos","events_url":"https://api.github.com/users/effuse/events{/privacy}","received_events_url":"https://api.github.com/users/effuse/received_events","type":"Organization","site_admin":false},"repo":{"id":13682968,"name":"profuse","full_name":"effuse/profuse","owner":{"login":"effuse","id":19324163,"avatar_url":"https://avatars.githubusercontent.com/u/19324163?v=3","gravatar_id":"","url":"https://api.github.com/users/effuse","html_url":"https://github.com/effuse","followers_url":"https://api.github.com/users/effuse/followers","following_url":"https://api.github.com/users/effuse/following{/other_user}","gists_url":"https://api.github.com/users/effuse/gists{/gist_id}","starred_url":"https://api.github.com/users/effuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/effuse/subscriptions","organizations_url":"https://api.github.com/users/effuse/orgs","repos_url":"https://api.github.com/users/effuse/repos","events_url":"https://api.github.com/users/effuse/events{/privacy}","received_events_url":"https://api.github.com/users/effuse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/effuse/profuse","description":"An OCaml implementation of the FUSE protocol versions 7.8 and 7.23","fork":false,"url":"https://api.github.com/repos/effuse/profuse","forks_url":"https://api.github.com/repos/effuse/profuse/forks","keys_url":"https://api.github.com/repos/effuse/profuse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/effuse/profuse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/effuse/profuse/teams","hooks_url":"https://api.github.com/repos/effuse/profuse/hooks","issue_events_url":"https://api.github.com/repos/effuse/profuse/issues/events{/number}","events_url":"https://api.github.com/repos/effuse/profuse/events","assignees_url":"https://api.github.com/repos/effuse/profuse/assignees{/user}","branches_url":"https://api.github.com/repos/effuse/profuse/branches{/branch}","tags_url":"https://api.github.com/repos/effuse/profuse/tags","blobs_url":"https://api.github.com/repos/effuse/profuse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/effuse/profuse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/effuse/profuse/git/refs{/sha}","trees_url":"https://api.github.com/repos/effuse/profuse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/effuse/profuse/statuses/{sha}","languages_url":"https://api.github.com/repos/effuse/profuse/languages","stargazers_url":"https://api.github.com/repos/effuse/profuse/stargazers","contributors_url":"https://api.github.com/repos/effuse/profuse/contributors","subscribers_url":"https://api.github.com/repos/effuse/profuse/subscribers","subscription_url":"https://api.github.com/repos/effuse/profuse/subscription","commits_url":"https://api.github.com/repos/effuse/profuse/commits{/sha}","git_commits_url":"https://api.github.com/repos/effuse/profuse/git/commits{/sha}","comments_url":"https://api.github.com/repos/effuse/profuse/comments{/number}","issue_comment_url":"https://api.github.com/repos/effuse/profuse/issues/comments{/number}","contents_url":"https://api.github.com/repos/effuse/profuse/contents/{+path}","compare_url":"https://api.github.com/repos/effuse/profuse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/effuse/profuse/merges","archive_url":"https://api.github.com/repos/effuse/profuse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/effuse/profuse/downloads","issues_url":"https://api.github.com/repos/effuse/profuse/issues{/number}","pulls_url":"https://api.github.com/repos/effuse/profuse/pulls{/number}","milestones_url":"https://api.github.com/repos/effuse/profuse/milestones{/number}","notifications_url":"https://api.github.com/repos/effuse/profuse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/effuse/profuse/labels{/name}","releases_url":"https://api.github.com/repos/effuse/profuse/releases{/id}","deployments_url":"https://api.github.com/repos/effuse/profuse/deployments","created_at":"2013-10-18T16:18:36Z","updated_at":"2016-06-08T13:54:18Z","pushed_at":"2016-07-15T12:35:16Z","git_url":"git://github.com/effuse/profuse.git","ssh_url":"git@github.com:effuse/profuse.git","clone_url":"https://github.com/effuse/profuse.git","svn_url":"https://github.com/effuse/profuse","homepage":"","size":439,"stargazers_count":22,"watchers_count":22,"language":"OCaml","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":9,"forks":5,"open_issues":9,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/effuse/profuse/pulls/58"},"html":{"href":"https://github.com/effuse/profuse/pull/58"},"issue":{"href":"https://api.github.com/repos/effuse/profuse/issues/58"},"comments":{"href":"https://api.github.com/repos/effuse/profuse/issues/58/comments"},"review_comments":{"href":"https://api.github.com/repos/effuse/profuse/pulls/58/comments"},"review_comment":{"href":"https://api.github.com/repos/effuse/profuse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/effuse/profuse/pulls/58/commits"},"statuses":{"href":"https://api.github.com/repos/effuse/profuse/statuses/1c416465574844077f0607186b69fb395b7914ad"}}}}
{"actor":{"display_login":"yallop"}}