diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-12-23 17:04:26 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-12-23 17:04:26 -0500 |
| commit | c00216701c64269a2395e84f3ccff99d6fb89ffc (patch) | |
| tree | 9fa071b9e96f9eadc5069b71634b11fc13b00839 /src/buffer.hpp | |
| parent | c21884e1d64e4193e03be4f3064917a26b34b142 (diff) | |
| parent | 45081c1e9cc28757cb563c77553631f7a92b29d8 (diff) | |
| download | zig-c00216701c64269a2395e84f3ccff99d6fb89ffc.tar.gz zig-c00216701c64269a2395e84f3ccff99d6fb89ffc.zip | |
Merge remote-tracking branch 'origin/master' into llvm8
Diffstat (limited to 'src/buffer.hpp')
| -rw-r--r-- | src/buffer.hpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/buffer.hpp b/src/buffer.hpp index 8155df87a1..afe9fd8a91 100644 --- a/src/buffer.hpp +++ b/src/buffer.hpp @@ -181,5 +181,15 @@ static inline Slice<uint8_t> buf_to_slice(Buf *buf) { return Slice<uint8_t>{reinterpret_cast<uint8_t*>(buf_ptr(buf)), buf_len(buf)}; } +static inline void buf_replace(Buf* buf, char from, char to) { + const size_t count = buf_len(buf); + char* ptr = buf_ptr(buf); + for (size_t i = 0; i < count; ++i) { + char& l = ptr[i]; + if (l == from) + l = to; + } +} + #endif |
