Skip to content

Commit

Permalink
Avoid a few unneeded copies
Browse files Browse the repository at this point in the history
  • Loading branch information
syyyr committed Nov 25, 2024
1 parent 3aa36c6 commit 53996d6
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
3 changes: 1 addition & 2 deletions libshvbroker/src/brokeraclnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ chainpack::RpcValue RolesAclNode::callMethod(const iotqt::node::ShvNode::StringV
if(shv_path.empty()) {
if(method == M_SET_VALUE) {
if(params.isList()) {
const auto p = params;
const auto &lst = p.asList();
const auto &lst = params.asList();
const std::string role_name = lst.value(0).asString();

chainpack::RpcValue rv = lst.value(1);
Expand Down
2 changes: 1 addition & 1 deletion libshvbroker/src/brokerapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ auto transform_cli_group_mapping(const chainpack::RpcList& cli_group_mapping)
cli_group_mapping.end(),
std::back_inserter(group_mapping),
[] (const auto& mapping) {
auto mapping_list = mapping.asList();
const auto& mapping_list = mapping.asList();
if (mapping_list.size() != 2) {
#ifdef _MSC_VER
SHV_EXCEPTION(__FUNCSIG__ + std::string{": group mapping isn't a pair."});
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/tests/test_chainpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ DOCTEST_TEST_CASE("ChainPack")
}
ChainPackReader rd(out); RpcValue cp2 = rd.read();
nDebug() << cp2.toCpon() << " dump: " << binary_dump(out.str()).c_str();
const RpcList list = cp2.asList();
const RpcList& list = cp2.asList();
REQUIRE(list.size() == N);
for (size_t i = 0; i < list.size(); ++i) {
std::string s("foo-bar");
Expand Down
3 changes: 1 addition & 2 deletions libshvcore/src/utils/shvtypeinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,10 @@ ShvPropertyDescr &ShvPropertyDescr::addMethod(const ShvMethodDescr &method_descr

ShvPropertyDescr &ShvPropertyDescr::setMethod(const ShvMethodDescr &method_descr)
{
auto name = method_descr.name();
auto method_list = methods();
bool method_found = false;
for(auto &mm : method_list) {
if(mm.name() == name) {
if(mm.name() == method_descr.name()) {
mm = method_descr;
method_found = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion libshviotqt/src/node/shvnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void ShvNode::treeWalk_helper(std::function<void (ShvNode *, const ShvNode::Stri

chainpack::RpcValue ShvNode::dir(const StringViewList &shv_path, const chainpack::RpcValue &methods_params)
{
auto method_name = methods_params.asString();
const auto& method_name = methods_params.asString();
size_t cnt = methodCount(shv_path);
if(method_name.empty()) {
RpcList ret;
Expand Down
10 changes: 5 additions & 5 deletions libshviotqt/tests/test_frame_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ vector<string> msg_to_raw_data_serial(const vector<string> &cpons, SerialFrameWr

void test_valid_data(FrameReader *rd, const vector<string> &data)
{
auto rq1 = data[0];
auto rs1 = data[1];
auto rs2 = data[2];
auto sig1 = data[3];
const auto& rq1 = data[0];
const auto& rs1 = data[1];
const auto& rs2 = data[2];
const auto& sig1 = data[3];
{
auto ret = rd->addData(rq1);
REQUIRE(ret.isEmpty());
Expand All @@ -96,7 +96,7 @@ void test_valid_data(FrameReader *rd, const vector<string> &data)

void test_incomplete_data(FrameReader *rd, const vector<string> &data)
{
auto rs1 = data[1];
const auto& rs1 = data[1];
vector<string> chunks;
vector<size_t> ixs = {0, 4, rs1.size() - 2, rs1.size()};
for (size_t i = 1; i < ixs.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion libshvvisu/src/timeline/channelfiltermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void ChannelFilterModel::createNodesForPath(const QString &path, const QMap<QStr
QStandardItem *it = shvPathToItem(sub_path, invisibleRootItem());

if (!it) {
QString dir_name = path_list.at(i);
const auto& dir_name = path_list.at(i);
auto *item = new QStandardItem(dir_name);
item->setData(dir_name, UserData::DirName);

Expand Down

0 comments on commit 53996d6

Please sign in to comment.