mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 06:35:12 +00:00
(perf): Add missing move in sp matrix caster and microopt char concats (#3823)
* Add missing move in sp matrix caster and microopt char concat * Remove useless move * Add a couple more std::move * Missed one char * Improve error_string * Ensure no temp reallocs in errorString concat * Remove useless move
This commit is contained in:
parent
b22ee64c73
commit
47079b9e7b
@ -225,8 +225,8 @@ PYBIND11_NOINLINE detail::type_info *get_type_info(const std::type_index &tp,
|
||||
if (throw_if_missing) {
|
||||
std::string tname = tp.name();
|
||||
detail::clean_type_id(tname);
|
||||
pybind11_fail("pybind11::detail::get_type_info: unable to find type info for \"" + tname
|
||||
+ "\"");
|
||||
pybind11_fail("pybind11::detail::get_type_info: unable to find type info for \""
|
||||
+ std::move(tname) + '"');
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -512,9 +512,13 @@ PYBIND11_NOINLINE std::string error_string() {
|
||||
Py_INCREF(f_code);
|
||||
# endif
|
||||
int lineno = PyFrame_GetLineNumber(frame);
|
||||
errorString += " " + handle(f_code->co_filename).cast<std::string>() + "("
|
||||
+ std::to_string(lineno)
|
||||
+ "): " + handle(f_code->co_name).cast<std::string>() + "\n";
|
||||
errorString += " ";
|
||||
errorString += handle(f_code->co_filename).cast<std::string>();
|
||||
errorString += '(';
|
||||
errorString += std::to_string(lineno);
|
||||
errorString += "): ";
|
||||
errorString += handle(f_code->co_name).cast<std::string>();
|
||||
errorString += '\n';
|
||||
Py_DECREF(f_code);
|
||||
# if PY_VERSION_HEX >= 0x030900B1
|
||||
auto *b_frame = PyFrame_GetBack(frame);
|
||||
|
@ -668,7 +668,7 @@ struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
|
||||
Type::Flags &(Eigen::RowMajor | Eigen::ColMajor),
|
||||
StorageIndex>(shape[0].cast<Index>(),
|
||||
shape[1].cast<Index>(),
|
||||
nnz,
|
||||
std::move(nnz),
|
||||
outerIndices.mutable_data(),
|
||||
innerIndices.mutable_data(),
|
||||
values.mutable_data());
|
||||
@ -686,7 +686,8 @@ struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
|
||||
array outerIndices((rowMajor ? src.rows() : src.cols()) + 1, src.outerIndexPtr());
|
||||
array innerIndices(src.nonZeros(), src.innerIndexPtr());
|
||||
|
||||
return matrix_type(std::make_tuple(data, innerIndices, outerIndices),
|
||||
return matrix_type(std::make_tuple(
|
||||
std::move(data), std::move(innerIndices), std::move(outerIndices)),
|
||||
std::make_pair(src.rows(), src.cols()))
|
||||
.release();
|
||||
}
|
||||
|
@ -940,7 +940,7 @@ protected:
|
||||
|
||||
void fail_dim_check(ssize_t dim, const std::string &msg) const {
|
||||
throw index_error(msg + ": " + std::to_string(dim) + " (ndim = " + std::to_string(ndim())
|
||||
+ ")");
|
||||
+ ')');
|
||||
}
|
||||
|
||||
template <typename... Ix>
|
||||
@ -1144,11 +1144,11 @@ struct format_descriptor<T, detail::enable_if_t<detail::is_pod_struct<T>::value>
|
||||
|
||||
template <size_t N>
|
||||
struct format_descriptor<char[N]> {
|
||||
static std::string format() { return std::to_string(N) + "s"; }
|
||||
static std::string format() { return std::to_string(N) + 's'; }
|
||||
};
|
||||
template <size_t N>
|
||||
struct format_descriptor<std::array<char, N>> {
|
||||
static std::string format() { return std::to_string(N) + "s"; }
|
||||
static std::string format() { return std::to_string(N) + 's'; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -561,14 +561,14 @@ protected:
|
||||
for (auto *it = chain_start; it != nullptr; it = it->next) {
|
||||
if (options::show_function_signatures()) {
|
||||
if (index > 0) {
|
||||
signatures += "\n";
|
||||
signatures += '\n';
|
||||
}
|
||||
if (chain) {
|
||||
signatures += std::to_string(++index) + ". ";
|
||||
}
|
||||
signatures += rec->name;
|
||||
signatures += it->signature;
|
||||
signatures += "\n";
|
||||
signatures += '\n';
|
||||
}
|
||||
if (it->doc && it->doc[0] != '\0' && options::show_user_defined_docstrings()) {
|
||||
// If we're appending another docstring, and aren't printing function signatures,
|
||||
@ -577,15 +577,15 @@ protected:
|
||||
if (first_user_def) {
|
||||
first_user_def = false;
|
||||
} else {
|
||||
signatures += "\n";
|
||||
signatures += '\n';
|
||||
}
|
||||
}
|
||||
if (options::show_function_signatures()) {
|
||||
signatures += "\n";
|
||||
signatures += '\n';
|
||||
}
|
||||
signatures += it->doc;
|
||||
if (options::show_function_signatures()) {
|
||||
signatures += "\n";
|
||||
signatures += '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1055,7 +1055,7 @@ protected:
|
||||
msg += it2->signature;
|
||||
}
|
||||
|
||||
msg += "\n";
|
||||
msg += '\n';
|
||||
}
|
||||
msg += "\nInvoked with: ";
|
||||
auto args_ = reinterpret_borrow<tuple>(args_in);
|
||||
|
Loading…
Reference in New Issue
Block a user