From a9d85e8f8ea8ffb75bdf0927fa263fd01d9308be Mon Sep 17 00:00:00 2001 From: Christian Gruber Date: Tue, 2 Jun 2020 08:16:50 +0200 Subject: [PATCH] Use std::vector of const char* instead of std::string where meaningful This avoids additional string allocation --- gnucash/import-export/test/gtest-import-backend.cpp | 2 +- libgnucash/engine/mocks/gmock-Account.cpp | 4 ++-- libgnucash/engine/mocks/gmock-Account.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gnucash/import-export/test/gtest-import-backend.cpp b/gnucash/import-export/test/gtest-import-backend.cpp index eedcfba924..0f67ee9095 100644 --- a/gnucash/import-export/test/gtest-import-backend.cpp +++ b/gnucash/import-export/test/gtest-import-backend.cpp @@ -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 diff --git a/libgnucash/engine/mocks/gmock-Account.cpp b/libgnucash/engine/mocks/gmock-Account.cpp index 5152d88662..2e5f370606 100644 --- a/libgnucash/engine/mocks/gmock-Account.cpp +++ b/libgnucash/engine/mocks/gmock-Account.cpp @@ -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 tokenVec; + std::vector 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 tokenVec; + std::vector tokenVec; for (auto token = tokens; token; token = token->next) { diff --git a/libgnucash/engine/mocks/gmock-Account.h b/libgnucash/engine/mocks/gmock-Account.h index 2a39efe6fa..ee00366043 100644 --- a/libgnucash/engine/mocks/gmock-Account.h +++ b/libgnucash/engine/mocks/gmock-Account.h @@ -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)); - MOCK_METHOD2(addAccountBayes, void(std::vector, Account*)); + MOCK_METHOD1(findAccountBayes, Account *(std::vector)); + MOCK_METHOD2(addAccountBayes, void(std::vector, Account*)); }; #endif