diff options
author | Tor Brede Vekterli <vekterli@oath.com> | 2018-07-25 14:24:21 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@oath.com> | 2018-07-25 14:24:21 +0000 |
commit | 12c8f3005e202b31a8e0ff3816ce9d714a269046 (patch) | |
tree | a5d9ba0eedc49df2cea2dbdfea677c4c37ed3775 /eval | |
parent | e3af3d215feb1e416b27b92bbf421dde281f3a09 (diff) |
Remove stringref::c_str()
The expected semantics of c_str() (a null-terminated string) cannot
be satisfied with a string reference, so remove the function entirely
to prevent people from using it in buggy ways.
Replaces c_str() with data() in places where it is presumed safe,
otherwise constructs temporary string instances. Certain callsites
have been de-stringref'd in favor of regular strings, in particular
where C APIs have been transitively called. The vast majority of
these were called with string parameters anyway, so should not
cause much extra allocation.
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp | 2 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp b/eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp index 80548d33e72..f2ddcb38698 100644 --- a/eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp +++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp @@ -67,7 +67,7 @@ checkDimensions(const DenseTensorView &lhs, const DenseTensorView &rhs, "dense tensor %s, " "lhs dimensions = '%s', " "rhs dimensions = '%s'", - operation.c_str(), + operation.data(), dimensionsAsString(lhs.fast_type()).c_str(), dimensionsAsString(rhs.fast_type()).c_str())); } diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.h b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.h index 681bdabc5eb..7e69adb5804 100644 --- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.h +++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.h @@ -53,7 +53,7 @@ class SparseTensorUnsortedAddressBuilder ElementStringRef append(vespalib::stringref str) { - const char *cstr = str.c_str(); + const char *cstr = str.data(); uint32_t start = _elementStrings.size(); _elementStrings.insert(_elementStrings.end(), cstr, cstr + str.size() + 1); |