Skip to content

Commit

Permalink
Avoid Copy when converting Cord to bytes.
Browse files Browse the repository at this point in the history
#perf

PiperOrigin-RevId: 650674062
  • Loading branch information
CLIF Team authored and Ralf W. Grosse-Kunstleve committed Aug 27, 2024
1 parent 8ad1c33 commit a71818b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clif/python/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ PyObject* Clif_PyObjFrom(absl::string_view c, const py::PostConv& pc) {
#endif

PyObject* Clif_PyObjFrom(const absl::Cord& c, const py::PostConv& pc) {
std::string s(c);
PyObject* py = PyBytes_FromStringAndSize(s.c_str(), s.size());
PyObject* py = PyBytes_FromStringAndSize(nullptr, c.size());
if (!py) return nullptr;
c.CopyToArray(PyBytes_AS_STRING(py));
return pc.Apply(py);
}

Expand Down

0 comments on commit a71818b

Please sign in to comment.