Skip to content

Commit

Permalink
Root: Fix function parameter to const references
Browse files Browse the repository at this point in the history
値渡しではなくconst参照渡しにするべきとcppcheckに指摘されたため
メンバ関数の引数を修正します。

cppcheckのレポート
```
src/dbtree/root.h:172:49: performance: Function parameter 'old_root' should be passed by const reference. [passedByValue]
                              const std::string old_root,
                                                ^
src/dbtree/root.h:173:49: performance: Function parameter 'old_path_board' should be passed by const reference. [passedByValue]
                              const std::string old_path_board,
                                                ^
src/dbtree/root.h:174:49: performance: Function parameter 'new_root' should be passed by const reference. [passedByValue]
                              const std::string new_root,
                                                ^
src/dbtree/root.h:175:49: performance: Function parameter 'new_path_board' should be passed by const reference. [passedByValue]
                              const std::string new_path_board
                                                ^
src/dbtree/root.h:178:48: performance: Function parameter 'old_root' should be passed by const reference. [passedByValue]
        void push_movetable( const std::string old_root,
                                               ^
src/dbtree/root.h:179:48: performance: Function parameter 'old_path_board' should be passed by const reference. [passedByValue]
                             const std::string old_path_board,
                                               ^
src/dbtree/root.h:180:48: performance: Function parameter 'new_root' should be passed by const reference. [passedByValue]
                             const std::string new_root,
                                               ^
src/dbtree/root.h:181:48: performance: Function parameter 'new_path_board' should be passed by const reference. [passedByValue]
                             const std::string new_path_board
                                               ^
src/dbtree/root.cpp:784:42: performance: Function parameter 'old_root' should be passed by const reference. [passedByValue]
                       const std::string old_root,
                                         ^
src/dbtree/root.cpp:785:42: performance: Function parameter 'old_path_board' should be passed by const reference. [passedByValue]
                       const std::string old_path_board,
                                         ^
src/dbtree/root.cpp:786:42: performance: Function parameter 'new_root' should be passed by const reference. [passedByValue]
                       const std::string new_root,
                                         ^
src/dbtree/root.cpp:787:42: performance: Function parameter 'new_path_board' should be passed by const reference. [passedByValue]
                       const std::string new_path_board
                                         ^
src/dbtree/root.cpp:865:46: performance: Function parameter 'old_root' should be passed by const reference. [passedByValue]
void Root::push_movetable( const std::string old_root,
                                             ^
src/dbtree/root.cpp:866:46: performance: Function parameter 'old_path_board' should be passed by const reference. [passedByValue]
                           const std::string old_path_board,
                                             ^
src/dbtree/root.cpp:867:46: performance: Function parameter 'new_root' should be passed by const reference. [passedByValue]
                           const std::string new_root,
                                             ^
src/dbtree/root.cpp:868:46: performance: Function parameter 'new_path_board' should be passed by const reference. [passedByValue]
                           const std::string new_path_board
                                             ^
```
  • Loading branch information
ma8ma committed May 31, 2020
1 parent 358a28a commit 45e0ec4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
20 changes: 9 additions & 11 deletions src/dbtree/root.cpp
Expand Up @@ -781,12 +781,11 @@ bool Root::move_board( const std::string& url_old, const std::string& url_new, c
// 板移転処理実行
//
bool Root::exec_move_board( BoardBase* board,
const std::string old_root,
const std::string old_path_board,
const std::string new_root,
const std::string new_path_board
){

const std::string& old_root,
const std::string& old_path_board,
const std::string& new_root,
const std::string& new_path_board )
{
if( ! board ) return false;

#ifdef _SHOW_BOARD
Expand Down Expand Up @@ -863,11 +862,10 @@ bool Root::exec_move_board( BoardBase* board,
//
// 板移転テーブルを更新
//
void Root::push_movetable( const std::string old_root,
const std::string old_path_board,
const std::string new_root,
const std::string new_path_board
)
void Root::push_movetable( const std::string& old_root,
const std::string& old_path_board,
const std::string& new_root,
const std::string& new_path_board )
{
#ifdef _DEBUG
std::cout << "Root::push_movetable : " << old_root << old_path_board << " -> " << new_root << new_path_board << std::endl;
Expand Down
18 changes: 8 additions & 10 deletions src/dbtree/root.h
Expand Up @@ -169,18 +169,16 @@ namespace DBTREE

// 板移転処理
bool exec_move_board( BoardBase* board,
const std::string old_root,
const std::string old_path_board,
const std::string new_root,
const std::string new_path_board
);
const std::string& old_root,
const std::string& old_path_board,
const std::string& new_root,
const std::string& new_path_board );

// 板移転テーブルに追加
void push_movetable( const std::string old_root,
const std::string old_path_board,
const std::string new_root,
const std::string new_path_board
);
void push_movetable( const std::string& old_root,
const std::string& old_path_board,
const std::string& new_root,
const std::string& new_path_board );

// 板をデータベースから削除
bool remove_board( const std::string& url );
Expand Down

0 comments on commit 45e0ec4

Please sign in to comment.