{"action":"created","comment":{"url":"https://api.github.com/repos/c5t/Current/pulls/comments/32266270","id":32266270,"diff_hunk":"@@ -59,26 +61,84 @@ inline size_t StringLengthOrOneForChar(T&& param) {\n   return StringLengthOrOneForCharImpl<rmref<T>>::Length(param);\n }\n \n-template <typename T_VECTOR_STRING, typename T_SEPARATOR>\n-std::string Join(const T_VECTOR_STRING& strings, T_SEPARATOR&& separator) {\n-  if (strings.empty()) {\n-    return \"\";\n-  } else {\n+template <bool CAN_GET_LENGTH>\n+struct OptionallyReserveOutputBufferImpl {\n+  template <typename T_CONTAINER, typename T_SEPARATOR>\n+  static void Impl(std::string&, const T_CONTAINER&, T_SEPARATOR&&) {}\n+};\n+\n+template <>\n+struct OptionallyReserveOutputBufferImpl<true> {\n+  template <typename T_CONTAINER, typename T_SEPARATOR>\n+  static void Impl(std::string& output, const T_CONTAINER& components, T_SEPARATOR&& separator) {\n     size_t length = 0;\n-    for (const auto cit : strings) {\n+    for (const auto cit : components) {\n       length += cit.length();\n     }\n-    length += impl::StringLengthOrOneForChar(separator) * (strings.size() - 1);\n+    length += impl::StringLengthOrOneForChar(separator) * (components.size() - 1);\n+    output.reserve(length);\n+  }\n+};\n+\n+namespace sfinae {\n+\n+template <typename T>\n+struct HasBegin {\n+  template <typename... XS>\n+  static constexpr bool CompileTimeCheck(char) {\n+    return false;\n+  }\n+\n+  template <typename... XS>\n+  static constexpr auto CompileTimeCheck(int) -> decltype(std::declval<T>().begin(), bool()) {\n+    return true;\n+  }\n+};\n+\n+template <typename T, bool IS_CONTAINER>\n+struct IsContainerOfStringsImpl {};\n+\n+template <typename T>\n+struct IsContainerOfStringsImpl<T, false> {\n+  enum { value = false };\n+};\n+\n+template <typename T>\n+struct IsContainerOfStringsImpl<T, true> {\n+  enum { value = std::is_same<std::string, bricks::decay<decltype(*std::declval<T>().begin())>>::value };\n+};\n+\n+template <typename T>\n+struct IsContainerOfStrings {\n+  enum { value = IsContainerOfStringsImpl<T, HasBegin<T>::CompileTimeCheck(0)>::value };\n+};\n+\n+}  // namespace sfinae\n+\n+template <typename T_CONTAINER, typename T_SEPARATOR>\n+void OptionallyReserveOutputBuffer(std::string& output,\n+                                   const T_CONTAINER& components,\n+                                   T_SEPARATOR&& separator) {\n+  // Note: this implementation does not to `reserve()` for chars, the length of which is always known to be 1.","path":"Bricks/strings/join.h","position":78,"original_position":78,"commit_id":"e3fd029620343a8c44904239e59a4868c61b2850","original_commit_id":"e3fd029620343a8c44904239e59a4868c61b2850","user":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"body":"s/not to `reserve()`/not `reserve()`/","created_at":"2015-06-11T20:46:30Z","updated_at":"2015-06-11T20:46:30Z","html_url":"https://github.com/c5t/Current/pull/205#discussion_r32266270","pull_request_url":"https://api.github.com/repos/c5t/Current/pulls/205","_links":{"self":{"href":"https://api.github.com/repos/c5t/Current/pulls/comments/32266270"},"html":{"href":"https://github.com/c5t/Current/pull/205#discussion_r32266270"},"pull_request":{"href":"https://api.github.com/repos/c5t/Current/pulls/205"}}},"pull_request":{"url":"https://api.github.com/repos/c5t/Current/pulls/205","id":37504721,"html_url":"https://github.com/c5t/Current/pull/205","diff_url":"https://github.com/c5t/Current/pull/205.diff","patch_url":"https://github.com/c5t/Current/pull/205.patch","issue_url":"https://api.github.com/repos/c5t/Current/issues/205","number":205,"state":"open","locked":false,"title":"Enabled strings::Join(*).","user":{"login":"dkorolev","id":2159447,"avatar_url":"https://avatars.githubusercontent.com/u/2159447?v=3","gravatar_id":"","url":"https://api.github.com/users/dkorolev","html_url":"https://github.com/dkorolev","followers_url":"https://api.github.com/users/dkorolev/followers","following_url":"https://api.github.com/users/dkorolev/following{/other_user}","gists_url":"https://api.github.com/users/dkorolev/gists{/gist_id}","starred_url":"https://api.github.com/users/dkorolev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkorolev/subscriptions","organizations_url":"https://api.github.com/users/dkorolev/orgs","repos_url":"https://api.github.com/users/dkorolev/repos","events_url":"https://api.github.com/users/dkorolev/events{/privacy}","received_events_url":"https://api.github.com/users/dkorolev/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-11T20:24:45Z","updated_at":"2015-06-11T20:46:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7930225cf609122aa056a12497d36b7c980f2e3a","assignee":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/c5t/Current/pulls/205/commits","review_comments_url":"https://api.github.com/repos/c5t/Current/pulls/205/comments","review_comment_url":"https://api.github.com/repos/c5t/Current/pulls/comments{/number}","comments_url":"https://api.github.com/repos/c5t/Current/issues/205/comments","statuses_url":"https://api.github.com/repos/c5t/Current/statuses/e3fd029620343a8c44904239e59a4868c61b2850","head":{"label":"dkorolev:to_string","ref":"to_string","sha":"e3fd029620343a8c44904239e59a4868c61b2850","user":{"login":"dkorolev","id":2159447,"avatar_url":"https://avatars.githubusercontent.com/u/2159447?v=3","gravatar_id":"","url":"https://api.github.com/users/dkorolev","html_url":"https://github.com/dkorolev","followers_url":"https://api.github.com/users/dkorolev/followers","following_url":"https://api.github.com/users/dkorolev/following{/other_user}","gists_url":"https://api.github.com/users/dkorolev/gists{/gist_id}","starred_url":"https://api.github.com/users/dkorolev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkorolev/subscriptions","organizations_url":"https://api.github.com/users/dkorolev/orgs","repos_url":"https://api.github.com/users/dkorolev/repos","events_url":"https://api.github.com/users/dkorolev/events{/privacy}","received_events_url":"https://api.github.com/users/dkorolev/received_events","type":"User","site_admin":false},"repo":{"id":27625438,"name":"Current","full_name":"dkorolev/Current","owner":{"login":"dkorolev","id":2159447,"avatar_url":"https://avatars.githubusercontent.com/u/2159447?v=3","gravatar_id":"","url":"https://api.github.com/users/dkorolev","html_url":"https://github.com/dkorolev","followers_url":"https://api.github.com/users/dkorolev/followers","following_url":"https://api.github.com/users/dkorolev/following{/other_user}","gists_url":"https://api.github.com/users/dkorolev/gists{/gist_id}","starred_url":"https://api.github.com/users/dkorolev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkorolev/subscriptions","organizations_url":"https://api.github.com/users/dkorolev/orgs","repos_url":"https://api.github.com/users/dkorolev/repos","events_url":"https://api.github.com/users/dkorolev/events{/privacy}","received_events_url":"https://api.github.com/users/dkorolev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dkorolev/Current","description":"Current is a data-centric framework","fork":true,"url":"https://api.github.com/repos/dkorolev/Current","forks_url":"https://api.github.com/repos/dkorolev/Current/forks","keys_url":"https://api.github.com/repos/dkorolev/Current/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dkorolev/Current/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dkorolev/Current/teams","hooks_url":"https://api.github.com/repos/dkorolev/Current/hooks","issue_events_url":"https://api.github.com/repos/dkorolev/Current/issues/events{/number}","events_url":"https://api.github.com/repos/dkorolev/Current/events","assignees_url":"https://api.github.com/repos/dkorolev/Current/assignees{/user}","branches_url":"https://api.github.com/repos/dkorolev/Current/branches{/branch}","tags_url":"https://api.github.com/repos/dkorolev/Current/tags","blobs_url":"https://api.github.com/repos/dkorolev/Current/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dkorolev/Current/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dkorolev/Current/git/refs{/sha}","trees_url":"https://api.github.com/repos/dkorolev/Current/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dkorolev/Current/statuses/{sha}","languages_url":"https://api.github.com/repos/dkorolev/Current/languages","stargazers_url":"https://api.github.com/repos/dkorolev/Current/stargazers","contributors_url":"https://api.github.com/repos/dkorolev/Current/contributors","subscribers_url":"https://api.github.com/repos/dkorolev/Current/subscribers","subscription_url":"https://api.github.com/repos/dkorolev/Current/subscription","commits_url":"https://api.github.com/repos/dkorolev/Current/commits{/sha}","git_commits_url":"https://api.github.com/repos/dkorolev/Current/git/commits{/sha}","comments_url":"https://api.github.com/repos/dkorolev/Current/comments{/number}","issue_comment_url":"https://api.github.com/repos/dkorolev/Current/issues/comments{/number}","contents_url":"https://api.github.com/repos/dkorolev/Current/contents/{+path}","compare_url":"https://api.github.com/repos/dkorolev/Current/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dkorolev/Current/merges","archive_url":"https://api.github.com/repos/dkorolev/Current/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dkorolev/Current/downloads","issues_url":"https://api.github.com/repos/dkorolev/Current/issues{/number}","pulls_url":"https://api.github.com/repos/dkorolev/Current/pulls{/number}","milestones_url":"https://api.github.com/repos/dkorolev/Current/milestones{/number}","notifications_url":"https://api.github.com/repos/dkorolev/Current/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dkorolev/Current/labels{/name}","releases_url":"https://api.github.com/repos/dkorolev/Current/releases{/id}","created_at":"2014-12-06T06:52:51Z","updated_at":"2015-06-10T01:34:38Z","pushed_at":"2015-06-11T20:44:05Z","git_url":"git://github.com/dkorolev/Current.git","ssh_url":"git@github.com:dkorolev/Current.git","clone_url":"https://github.com/dkorolev/Current.git","svn_url":"https://github.com/dkorolev/Current","homepage":"","size":10213,"stargazers_count":1,"watchers_count":1,"language":"C++","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":1,"default_branch":"master"}},"base":{"label":"c5t:master","ref":"master","sha":"7e5cdcf129c160f7513f266b4c1482346cd5fd25","user":{"login":"c5t","id":12224789,"avatar_url":"https://avatars.githubusercontent.com/u/12224789?v=3","gravatar_id":"","url":"https://api.github.com/users/c5t","html_url":"https://github.com/c5t","followers_url":"https://api.github.com/users/c5t/followers","following_url":"https://api.github.com/users/c5t/following{/other_user}","gists_url":"https://api.github.com/users/c5t/gists{/gist_id}","starred_url":"https://api.github.com/users/c5t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c5t/subscriptions","organizations_url":"https://api.github.com/users/c5t/orgs","repos_url":"https://api.github.com/users/c5t/repos","events_url":"https://api.github.com/users/c5t/events{/privacy}","received_events_url":"https://api.github.com/users/c5t/received_events","type":"Organization","site_admin":false},"repo":{"id":27625425,"name":"Current","full_name":"c5t/Current","owner":{"login":"c5t","id":12224789,"avatar_url":"https://avatars.githubusercontent.com/u/12224789?v=3","gravatar_id":"","url":"https://api.github.com/users/c5t","html_url":"https://github.com/c5t","followers_url":"https://api.github.com/users/c5t/followers","following_url":"https://api.github.com/users/c5t/following{/other_user}","gists_url":"https://api.github.com/users/c5t/gists{/gist_id}","starred_url":"https://api.github.com/users/c5t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c5t/subscriptions","organizations_url":"https://api.github.com/users/c5t/orgs","repos_url":"https://api.github.com/users/c5t/repos","events_url":"https://api.github.com/users/c5t/events{/privacy}","received_events_url":"https://api.github.com/users/c5t/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c5t/Current","description":"Current is a data-centric framework.","fork":false,"url":"https://api.github.com/repos/c5t/Current","forks_url":"https://api.github.com/repos/c5t/Current/forks","keys_url":"https://api.github.com/repos/c5t/Current/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c5t/Current/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c5t/Current/teams","hooks_url":"https://api.github.com/repos/c5t/Current/hooks","issue_events_url":"https://api.github.com/repos/c5t/Current/issues/events{/number}","events_url":"https://api.github.com/repos/c5t/Current/events","assignees_url":"https://api.github.com/repos/c5t/Current/assignees{/user}","branches_url":"https://api.github.com/repos/c5t/Current/branches{/branch}","tags_url":"https://api.github.com/repos/c5t/Current/tags","blobs_url":"https://api.github.com/repos/c5t/Current/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c5t/Current/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c5t/Current/git/refs{/sha}","trees_url":"https://api.github.com/repos/c5t/Current/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c5t/Current/statuses/{sha}","languages_url":"https://api.github.com/repos/c5t/Current/languages","stargazers_url":"https://api.github.com/repos/c5t/Current/stargazers","contributors_url":"https://api.github.com/repos/c5t/Current/contributors","subscribers_url":"https://api.github.com/repos/c5t/Current/subscribers","subscription_url":"https://api.github.com/repos/c5t/Current/subscription","commits_url":"https://api.github.com/repos/c5t/Current/commits{/sha}","git_commits_url":"https://api.github.com/repos/c5t/Current/git/commits{/sha}","comments_url":"https://api.github.com/repos/c5t/Current/comments{/number}","issue_comment_url":"https://api.github.com/repos/c5t/Current/issues/comments{/number}","contents_url":"https://api.github.com/repos/c5t/Current/contents/{+path}","compare_url":"https://api.github.com/repos/c5t/Current/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c5t/Current/merges","archive_url":"https://api.github.com/repos/c5t/Current/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c5t/Current/downloads","issues_url":"https://api.github.com/repos/c5t/Current/issues{/number}","pulls_url":"https://api.github.com/repos/c5t/Current/pulls{/number}","milestones_url":"https://api.github.com/repos/c5t/Current/milestones{/number}","notifications_url":"https://api.github.com/repos/c5t/Current/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c5t/Current/labels{/name}","releases_url":"https://api.github.com/repos/c5t/Current/releases{/id}","created_at":"2014-12-06T06:52:23Z","updated_at":"2015-06-10T01:34:19Z","pushed_at":"2015-06-11T20:44:06Z","git_url":"git://github.com/c5t/Current.git","ssh_url":"git@github.com:c5t/Current.git","clone_url":"https://github.com/c5t/Current.git","svn_url":"https://github.com/c5t/Current","homepage":"","size":9256,"stargazers_count":12,"watchers_count":12,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":35,"forks":7,"open_issues":35,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/c5t/Current/pulls/205"},"html":{"href":"https://github.com/c5t/Current/pull/205"},"issue":{"href":"https://api.github.com/repos/c5t/Current/issues/205"},"comments":{"href":"https://api.github.com/repos/c5t/Current/issues/205/comments"},"review_comments":{"href":"https://api.github.com/repos/c5t/Current/pulls/205/comments"},"review_comment":{"href":"https://api.github.com/repos/c5t/Current/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/c5t/Current/pulls/205/commits"},"statuses":{"href":"https://api.github.com/repos/c5t/Current/statuses/e3fd029620343a8c44904239e59a4868c61b2850"}}}}