Skip to content

Commit

Permalink
fix COPY_INSTEAD_OF_MOVE of coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
pit-ray committed Jul 6, 2024
1 parent 47976c8 commit d920af1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/bind/mouse/focustextarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ namespace vind

if(min_distance > distance) {
nearest = elem ;
min_distance = distance ;
nearest_box = box ;
min_distance = std::move(distance) ;
nearest_box = std::move(box) ;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/bind/proc/exapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ namespace vind
util::create_process(
get_shell_startupdirectory(),
"cmd", util::concat_args("/c",
shell_cmd, shell_cmd_flag, cmd,
std::move(shell_cmd), std::move(shell_cmd_flag), std::move(cmd),
"& pause")) ;
}
else {
util::create_process(
get_shell_startupdirectory(),
shell_cmd, util::concat_args(shell_cmd_flag, cmd), false) ;
std::move(shell_cmd),
util::concat_args(std::move(shell_cmd_flag), std::move(cmd)), false) ;
}

Sleep(100) ; //wait until the window is selectable
Expand Down
36 changes: 18 additions & 18 deletions src/bind/syscmd/autocmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace vind
auto [event_str, patcmd] = core::extract_double_args(pargs) ;
auto [pattern, cmd] = core::extract_double_args(patcmd) ;

std::vector<core::AutoCmdEvent> events ;
std::vector<core::AutoCmdEvent> event_list ;
for(const auto& event_str_part : util::split(event_str, ",")) {
auto event = core::get_autocmd_event(event_str_part) ;
if(event == core::AutoCmdEvent::UNDEFINED) {
Expand All @@ -39,7 +39,7 @@ namespace vind
return ;
}

events.push_back(event) ;
event_list.push_back(event) ;
}

if(pattern.empty()) {
Expand All @@ -51,7 +51,7 @@ namespace vind

return ;
}
auto patterns = util::split(pattern, ",") ;
auto pattern_list = util::split(std::move(pattern), ",") ;

if(cmd.empty()) {
opt::VCmdLine::print(
Expand All @@ -63,8 +63,8 @@ namespace vind
return ;
}

for(const auto event : events) {
for(const auto& aupat : patterns) {
for(const auto event : event_list) {
for(const auto& aupat : pattern_list) {
core::AutoCmd::get_instance().add(event, aupat, cmd) ;
}
}
Expand All @@ -83,24 +83,24 @@ namespace vind

auto [event_str, patcmd] = core::extract_double_args(pargs) ;
auto [pattern, cmd] = core::extract_double_args(patcmd) ;
auto patterns = util::split(std::move(pattern), ",") ;
auto pattern_list = util::split(std::move(pattern), ",") ;

if(event_str == "*") {
if(patterns.empty()) {
if(pattern_list.empty()) {
opt::VCmdLine::print(
opt::ErrorMessage("E: Empty autocmd pattern")) ;
core::Logger::get_instance().error(
"autocmd patterns are required for events containing wildcards, such as *.") ;
return ;
}

for(const auto& aupat : patterns) {
for(const auto& aupat : pattern_list) {
ac.remove(aupat) ;
}
return ;
}

std::vector<core::AutoCmdEvent> events ;
std::vector<core::AutoCmdEvent> event_list ;
for(const auto& event_str_part : util::split(event_str, ",")) {
auto event = core::get_autocmd_event(event_str_part) ;
if(event == core::AutoCmdEvent::UNDEFINED) {
Expand All @@ -111,31 +111,31 @@ namespace vind
event_str + " is an unsupported event name.") ;
return ;
}
events.push_back(event) ;
event_list.push_back(event) ;
}

if(patterns.empty()) {
for(const auto event : events) {
if(pattern_list.empty()) {
for(const auto event : event_list) {
ac.remove(event) ;
}
return ;
}
if(cmd.empty()) {
for(const auto event : events) {
for(const auto& aupat : patterns) {
for(const auto event : event_list) {
for(const auto& aupat : pattern_list) {
ac.remove(event, aupat) ;
}
}
return ;
}

for(const auto event : events) {
for(const auto& aupat : patterns) {
for(const auto event : event_list) {
for(const auto& aupat : pattern_list) {
ac.remove(event, aupat) ;
}
}
for(const auto event : events) {
for(const auto& aupat : patterns) {
for(const auto event : event_list) {
for(const auto& aupat : pattern_list) {
ac.add(event, aupat, cmd) ;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/bind/syscmd/set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace vind
}

// set option_name
auto key = core::extract_single_arg(util::A2a(pargs)) ;
auto key = core::extract_single_arg(util::A2a(std::move(pargs))) ;

bool flag_value = true ;
if(key.size() > 2 && key[0] == 'n' && key[1] == 'o') {
Expand Down
2 changes: 1 addition & 1 deletion src/bind/syscmd/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ namespace vind
path = core::RC() ;
}
else {
path = core::replace_path_magic(pargs) ;
path = core::replace_path_magic(std::move(pargs)) ;
}

std::ifstream ifs(path, std::ios::in) ;
Expand Down
2 changes: 1 addition & 1 deletion src/core/inputgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ namespace vind

std::vector<KeyCode> keyset(target.begin(), target.end()) ;
std::sort(keyset.begin(), keyset.end()) ;
pimpl->k2ks_map_[static_cast<int>(mode)][trigger_code] = keyset ;
pimpl->k2ks_map_[static_cast<int>(mode)][trigger_code] = std::move(keyset) ;
}
} // namespace core
} // namespace vind
Expand Down
2 changes: 1 addition & 1 deletion src/core/keycode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ namespace
longest = name ;
}
}
code2name_[code] = longest ;
code2name_[code] = std::move(longest) ;

continue ;
}
Expand Down

0 comments on commit d920af1

Please sign in to comment.