Use std::vector of const char* instead of std::string where meaningful

This avoids additional string allocation
This commit is contained in:
Christian Gruber
2020-06-02 08:16:50 +02:00
parent 6071202c0f
commit a9d85e8f8e
3 changed files with 5 additions and 5 deletions

View File

@@ -248,7 +248,7 @@ TEST_F(ImportBackendBayesTest, CreateTransInfo)
// check tokens created from transaction
EXPECT_CALL(imap, findAccountBayes(AllOf(
Each(Not(IsEmpty())), // tokens must not be empty strings
Each(Not(StrEq(""))), // tokens must not be empty strings
Each(Not(HasSubstr(" "))), // tokens must not contain separator
Not(HasDuplicates()), // tokens must be unique
Contains(StrEq(local_day_of_week)), // tokens must contain local day of week

View File

@@ -85,7 +85,7 @@ gnc_account_imap_find_account_bayes (
GList *tokens)
{
// \todo use std::list instead of std::vector, since GList is a double-linked list like std::list
std::vector<std::string> tokenVec;
std::vector<const char*> tokenVec;
for (auto token = tokens; token; token = token->next)
{
@@ -102,7 +102,7 @@ gnc_account_imap_add_account_bayes (
Account *acc)
{
// \todo use std::list instead of std::vector, since GList is a double-linked list like std::list
std::vector<std::string> tokenVec;
std::vector<const char*> tokenVec;
for (auto token = tokens; token; token = token->next)
{

View File

@@ -62,8 +62,8 @@ public:
MOCK_METHOD2(findAccount, Account *(const char*, const char*));
MOCK_METHOD3(addAccount, void(const char*, const char*, Account*));
MOCK_METHOD1(findAccountBayes, Account *(std::vector<std::string>));
MOCK_METHOD2(addAccountBayes, void(std::vector<std::string>, Account*));
MOCK_METHOD1(findAccountBayes, Account *(std::vector<const char*>));
MOCK_METHOD2(addAccountBayes, void(std::vector<const char*>, Account*));
};
#endif