{"action":"created","comment":{"url":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/comments/101905859","pull_request_review_id":22649408,"id":101905859,"diff_hunk":"@@ -107,34 +116,56 @@ func (builder *graphBuilder) readNodes(nodes map[string]*Node) {\n \t}\n }\n \n-func (builder *graphBuilder) extract() ([]*GraphNode, []*GraphLink) {\n-\tlinks := make([]*GraphLink, len(builder.links))\n-\tnodes := make([]*GraphNode, len(builder.macToID))\n-\tidToIndex := make(map[string]int)\n+type graphNodeCache struct {\n+\tbuilder   *graphBuilder\n+\ti         int\n+\tnodes     []*GraphNode\n+\tidToIndex map[string]int\n+}\n \n-\t// collect nodes and create mapping to index\n-\ti := 0\n-\tfor mac, nodeID := range builder.macToID {\n-\t\tnodes[i] = &GraphNode{\n-\t\t\tID:     mac,\n+func newGraphNodeCache(builder *graphBuilder) *graphNodeCache {\n+\treturn &graphNodeCache{\n+\t\tbuilder:   builder,\n+\t\ti:         0,\n+\t\tidToIndex: make(map[string]int),\n+\t\tnodes:     make([]*GraphNode, len(builder.macToID)),\n+\t}\n+}\n+\n+func (gn *graphNodeCache) GetIndex(nodeID string) int {\n+\tif gn.idToIndex[nodeID] == 0 {\n+\t\tgn.nodes[gn.i] = &GraphNode{\n+\t\t\tID:     gn.builder.idToMac[nodeID],\n \t\t\tNodeID: nodeID,\n \t\t}\n-\t\tidToIndex[nodeID] = i\n-\t\ti++\n+\t\tgn.idToIndex[nodeID] = gn.i\n+\t\tgn.i++\n \t}\n+\treturn gn.idToIndex[nodeID]","path":"models/graph.go","position":74,"original_position":74,"commit_id":"5bdc2384be09a7814d2ca6c1bf3db6db449aafa7","original_commit_id":"5bdc2384be09a7814d2ca6c1bf3db6db449aafa7","user":{"login":"corny","id":23553,"avatar_url":"https://avatars.githubusercontent.com/u/23553?v=3","gravatar_id":"","url":"https://api.github.com/users/corny","html_url":"https://github.com/corny","followers_url":"https://api.github.com/users/corny/followers","following_url":"https://api.github.com/users/corny/following{/other_user}","gists_url":"https://api.github.com/users/corny/gists{/gist_id}","starred_url":"https://api.github.com/users/corny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corny/subscriptions","organizations_url":"https://api.github.com/users/corny/orgs","repos_url":"https://api.github.com/users/corny/repos","events_url":"https://api.github.com/users/corny/events{/privacy}","received_events_url":"https://api.github.com/users/corny/received_events","type":"User","site_admin":false},"body":"When creating the element you do two lookups to the map. :-1: ","created_at":"2017-02-19T00:32:30Z","updated_at":"2017-02-19T00:35:02Z","html_url":"https://github.com/FreifunkBremen/respond-collector/pull/22#discussion_r101905859","pull_request_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/comments/101905859"},"html":{"href":"https://github.com/FreifunkBremen/respond-collector/pull/22#discussion_r101905859"},"pull_request":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/22","id":103703322,"html_url":"https://github.com/FreifunkBremen/respond-collector/pull/22","diff_url":"https://github.com/FreifunkBremen/respond-collector/pull/22.diff","patch_url":"https://github.com/FreifunkBremen/respond-collector/pull/22.patch","issue_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues/22","number":22,"state":"open","locked":false,"title":"Remove nodes without links from graph.json","user":{"login":"genofire","id":6905586,"avatar_url":"https://avatars.githubusercontent.com/u/6905586?v=3","gravatar_id":"","url":"https://api.github.com/users/genofire","html_url":"https://github.com/genofire","followers_url":"https://api.github.com/users/genofire/followers","following_url":"https://api.github.com/users/genofire/following{/other_user}","gists_url":"https://api.github.com/users/genofire/gists{/gist_id}","starred_url":"https://api.github.com/users/genofire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genofire/subscriptions","organizations_url":"https://api.github.com/users/genofire/orgs","repos_url":"https://api.github.com/users/genofire/repos","events_url":"https://api.github.com/users/genofire/events{/privacy}","received_events_url":"https://api.github.com/users/genofire/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-01-30T09:45:41Z","updated_at":"2017-02-19T00:35:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09851409101c887f7fc0f14b9e890810054d2043","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/22/commits","review_comments_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/22/comments","review_comment_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues/22/comments","statuses_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/statuses/5bdc2384be09a7814d2ca6c1bf3db6db449aafa7","head":{"label":"FreifunkBremen:needed_nodes","ref":"needed_nodes","sha":"5bdc2384be09a7814d2ca6c1bf3db6db449aafa7","user":{"login":"FreifunkBremen","id":6204341,"avatar_url":"https://avatars.githubusercontent.com/u/6204341?v=3","gravatar_id":"","url":"https://api.github.com/users/FreifunkBremen","html_url":"https://github.com/FreifunkBremen","followers_url":"https://api.github.com/users/FreifunkBremen/followers","following_url":"https://api.github.com/users/FreifunkBremen/following{/other_user}","gists_url":"https://api.github.com/users/FreifunkBremen/gists{/gist_id}","starred_url":"https://api.github.com/users/FreifunkBremen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FreifunkBremen/subscriptions","organizations_url":"https://api.github.com/users/FreifunkBremen/orgs","repos_url":"https://api.github.com/users/FreifunkBremen/repos","events_url":"https://api.github.com/users/FreifunkBremen/events{/privacy}","received_events_url":"https://api.github.com/users/FreifunkBremen/received_events","type":"Organization","site_admin":false},"repo":{"id":52072179,"name":"respond-collector","full_name":"FreifunkBremen/respond-collector","owner":{"login":"FreifunkBremen","id":6204341,"avatar_url":"https://avatars.githubusercontent.com/u/6204341?v=3","gravatar_id":"","url":"https://api.github.com/users/FreifunkBremen","html_url":"https://github.com/FreifunkBremen","followers_url":"https://api.github.com/users/FreifunkBremen/followers","following_url":"https://api.github.com/users/FreifunkBremen/following{/other_user}","gists_url":"https://api.github.com/users/FreifunkBremen/gists{/gist_id}","starred_url":"https://api.github.com/users/FreifunkBremen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FreifunkBremen/subscriptions","organizations_url":"https://api.github.com/users/FreifunkBremen/orgs","repos_url":"https://api.github.com/users/FreifunkBremen/repos","events_url":"https://api.github.com/users/FreifunkBremen/events{/privacy}","received_events_url":"https://api.github.com/users/FreifunkBremen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FreifunkBremen/respond-collector","description":"A collector for respondd to be used with MeshViewer, InfluxDB and Grafana","fork":false,"url":"https://api.github.com/repos/FreifunkBremen/respond-collector","forks_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/forks","keys_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/teams","hooks_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/hooks","issue_events_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues/events{/number}","events_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/events","assignees_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/assignees{/user}","branches_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/branches{/branch}","tags_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/tags","blobs_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/refs{/sha}","trees_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/statuses/{sha}","languages_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/languages","stargazers_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/stargazers","contributors_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/contributors","subscribers_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/subscribers","subscription_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/subscription","commits_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/commits{/sha}","git_commits_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/commits{/sha}","comments_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/comments{/number}","issue_comment_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues/comments{/number}","contents_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/contents/{+path}","compare_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/merges","archive_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/downloads","issues_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues{/number}","pulls_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls{/number}","milestones_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/milestones{/number}","notifications_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/labels{/name}","releases_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/releases{/id}","deployments_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/deployments","created_at":"2016-02-19T08:13:47Z","updated_at":"2016-11-29T16:41:13Z","pushed_at":"2017-02-19T00:21:34Z","git_url":"git://github.com/FreifunkBremen/respond-collector.git","ssh_url":"git@github.com:FreifunkBremen/respond-collector.git","clone_url":"https://github.com/FreifunkBremen/respond-collector.git","svn_url":"https://github.com/FreifunkBremen/respond-collector","homepage":"","size":162,"stargazers_count":5,"watchers_count":5,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":5,"default_branch":"master"}},"base":{"label":"FreifunkBremen:master","ref":"master","sha":"3e342ce7383aa30cee6ee5f2d3db5f7759e30043","user":{"login":"FreifunkBremen","id":6204341,"avatar_url":"https://avatars.githubusercontent.com/u/6204341?v=3","gravatar_id":"","url":"https://api.github.com/users/FreifunkBremen","html_url":"https://github.com/FreifunkBremen","followers_url":"https://api.github.com/users/FreifunkBremen/followers","following_url":"https://api.github.com/users/FreifunkBremen/following{/other_user}","gists_url":"https://api.github.com/users/FreifunkBremen/gists{/gist_id}","starred_url":"https://api.github.com/users/FreifunkBremen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FreifunkBremen/subscriptions","organizations_url":"https://api.github.com/users/FreifunkBremen/orgs","repos_url":"https://api.github.com/users/FreifunkBremen/repos","events_url":"https://api.github.com/users/FreifunkBremen/events{/privacy}","received_events_url":"https://api.github.com/users/FreifunkBremen/received_events","type":"Organization","site_admin":false},"repo":{"id":52072179,"name":"respond-collector","full_name":"FreifunkBremen/respond-collector","owner":{"login":"FreifunkBremen","id":6204341,"avatar_url":"https://avatars.githubusercontent.com/u/6204341?v=3","gravatar_id":"","url":"https://api.github.com/users/FreifunkBremen","html_url":"https://github.com/FreifunkBremen","followers_url":"https://api.github.com/users/FreifunkBremen/followers","following_url":"https://api.github.com/users/FreifunkBremen/following{/other_user}","gists_url":"https://api.github.com/users/FreifunkBremen/gists{/gist_id}","starred_url":"https://api.github.com/users/FreifunkBremen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FreifunkBremen/subscriptions","organizations_url":"https://api.github.com/users/FreifunkBremen/orgs","repos_url":"https://api.github.com/users/FreifunkBremen/repos","events_url":"https://api.github.com/users/FreifunkBremen/events{/privacy}","received_events_url":"https://api.github.com/users/FreifunkBremen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FreifunkBremen/respond-collector","description":"A collector for respondd to be used with MeshViewer, InfluxDB and Grafana","fork":false,"url":"https://api.github.com/repos/FreifunkBremen/respond-collector","forks_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/forks","keys_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/teams","hooks_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/hooks","issue_events_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues/events{/number}","events_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/events","assignees_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/assignees{/user}","branches_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/branches{/branch}","tags_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/tags","blobs_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/refs{/sha}","trees_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/statuses/{sha}","languages_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/languages","stargazers_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/stargazers","contributors_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/contributors","subscribers_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/subscribers","subscription_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/subscription","commits_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/commits{/sha}","git_commits_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/git/commits{/sha}","comments_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/comments{/number}","issue_comment_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues/comments{/number}","contents_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/contents/{+path}","compare_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/merges","archive_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/downloads","issues_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues{/number}","pulls_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls{/number}","milestones_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/milestones{/number}","notifications_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/labels{/name}","releases_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/releases{/id}","deployments_url":"https://api.github.com/repos/FreifunkBremen/respond-collector/deployments","created_at":"2016-02-19T08:13:47Z","updated_at":"2016-11-29T16:41:13Z","pushed_at":"2017-02-19T00:21:34Z","git_url":"git://github.com/FreifunkBremen/respond-collector.git","ssh_url":"git@github.com:FreifunkBremen/respond-collector.git","clone_url":"https://github.com/FreifunkBremen/respond-collector.git","svn_url":"https://github.com/FreifunkBremen/respond-collector","homepage":"","size":162,"stargazers_count":5,"watchers_count":5,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/22"},"html":{"href":"https://github.com/FreifunkBremen/respond-collector/pull/22"},"issue":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues/22"},"comments":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/FreifunkBremen/respond-collector/statuses/5bdc2384be09a7814d2ca6c1bf3db6db449aafa7"}}}}
{"actor":{"display_login":"corny"}}