summaryrefslogtreecommitdiff
path: root/src/buffer.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-02-21 09:14:16 -0800
committerRussell Belfer <rb@github.com>2014-04-01 09:45:20 -0700
commit18234b14ad55157581ca26ec763afc1af3ec6e76 (patch)
tree0093ff2001a591cf08116d61fa57c912f4c26d3b /src/buffer.h
parent2450d4c63a58958100d1be0e5082efa930e09650 (diff)
downloadlibgit2-18234b14ad55157581ca26ec763afc1af3ec6e76.tar.gz
Add efficient git_buf join3 API
There are a few places where we need to join three strings to assemble a path. This adds a simple join3 function to avoid the comparatively expensive join_n (which calls strlen on each string twice).
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 4c852b3cb..dba594d97 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -98,8 +98,12 @@ void git_buf_truncate(git_buf *buf, size_t len);
void git_buf_shorten(git_buf *buf, size_t amount);
void git_buf_rtruncate_at_char(git_buf *path, char separator);
+/** General join with separator */
int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...);
+/** Fast join of two strings - first may legally point into `buf` data */
int git_buf_join(git_buf *buf, char separator, const char *str_a, const char *str_b);
+/** Fast join of three strings - cannot reference `buf` data */
+int git_buf_join3(git_buf *buf, char separator, const char *str_a, const char *str_b, const char *str_c);
/**
* Join two strings as paths, inserting a slash between as needed.