{"id":16218103,"url":"https://github.com/quasilyte/concat","last_synced_at":"2025-09-11T23:07:44.211Z","repository":{"id":57498418,"uuid":"141195424","full_name":"quasilyte/concat","owner":"quasilyte","description":"Demo repository for habr.com article about faster Go string concatenation.","archived":false,"fork":false,"pushed_at":"2018-07-17T22:30:08.000Z","size":10,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T01:51:10.595Z","etag":null,"topics":["concat","concatenation","go","golang","library","strings"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quasilyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-16T21:15:58.000Z","updated_at":"2023-11-02T08:54:26.000Z","dependencies_parsed_at":"2022-09-21T08:33:52.391Z","dependency_job_id":null,"html_url":"https://github.com/quasilyte/concat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/quasilyte/concat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fconcat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fconcat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fconcat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fconcat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quasilyte","download_url":"https://codeload.github.com/quasilyte/concat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fconcat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270082487,"owners_count":24523742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concat","concatenation","go","golang","library","strings"],"created_at":"2024-10-10T11:48:30.072Z","updated_at":"2025-08-12T15:10:27.974Z","avatar_url":"https://github.com/quasilyte.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Concat\n\nDemo package for [Ускорение конкатенации строк в Go своими руками](https://habr.com/post/417479/) article.\n\n### Overview\n\nThis package provides simple functions that return concatenation results.\nCan work faster than Go `+` operator.\n\nYou should not use this package, really. It's just an example.\n\n### Benchmarks\n\n```\nBenchmarkConcat2Operator/short-8         \t20000000\t        84.4 ns/op\nBenchmarkConcat2Operator/longer-8        \t10000000\t       158 ns/op\nBenchmarkConcat2Builder/short-8          \t20000000\t        70.7 ns/op\nBenchmarkConcat2Builder/longer-8         \t10000000\t       127 ns/op\nBenchmarkConcat2/short-8                 \t30000000\t        57.3 ns/op\nBenchmarkConcat2/longer-8                \t20000000\t       106 ns/op\nBenchmarkConcat3Operator/short-8         \t20000000\t       103 ns/op\nBenchmarkConcat3Operator/longer-8        \t10000000\t       217 ns/op\nBenchmarkConcat3Builder/short-8          \t20000000\t        89.9 ns/op\nBenchmarkConcat3Builder/longer-8         \t 5000000\t       249 ns/op\nBenchmarkConcat3/short-8                 \t20000000\t        85.0 ns/op\nBenchmarkConcat3/longer-8                \t10000000\t       189 ns/op\n```\n\nNumber one is unsafe concatenation, second is `strings.Builder` with preallocated\nbuffer and \"obvious\" concatenation is the slowest one... unless [CL123256](https://go-review.googlesource.com/c/go/+/123256) is applied.\n\nUsing the `benchstat`, here is the difference between `concat` and `+`:\n\n```\nname              old time/op  new time/op  delta\nConcat2/short-8   84.4ns ± 2%  64.3ns ± 4%  -23.85%  (p=0.000 n=14+15)\nConcat2/longer-8   138ns ± 1%   118ns ± 1%  -14.83%  (p=0.000 n=13+15)\nConcat3/short-8    105ns ± 5%    82ns ± 5%  -22.29%  (p=0.000 n=15+14)\nConcat3/longer-8   218ns ± 1%   192ns ± 1%  -11.95%  (p=0.000 n=15+15)\n```\n\nIf compared with AMD64 asm version for concat2:\n\n```\nname              old time/op  new time/op  delta\nConcat2/short-8   84.4ns ± 0%  56.9ns ± 5%  -32.54%  (p=0.000 n=15+15)\nConcat2/longer-8   138ns ± 1%   107ns ± 0%  -22.51%  (p=0.000 n=13+15)\n```\n\nAs a bonus, asm version also makes empty strings concatenation optimization,\njust like runtime version of concat would.\n\n### Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/Quasilyte/concat\"\n)\n\nfunc main() {\n\tv := \"world!\"\n\tfmt.Println(concat.Strings(\"hello, \", v)) // =\u003e \"hello, world!\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2Fconcat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquasilyte%2Fconcat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2Fconcat/lists"}