susumu.yata
null+****@clear*****
Fri Jul 25 17:46:09 JST 2014
susumu.yata 2014-07-25 17:46:09 +0900 (Fri, 25 Jul 2014) New Revision: fbfc0221197d1fc5c55cec04d0db6e28c19b5e0a https://github.com/groonga/grnxx/commit/fbfc0221197d1fc5c55cec04d0db6e28c19b5e0a Message: Update DB to use Array. Modified files: include/grnxx/db.hpp lib/grnxx/db.cpp Modified: include/grnxx/db.hpp (+2 -3) =================================================================== --- include/grnxx/db.hpp 2014-07-25 17:40:12 +0900 (e73a434) +++ include/grnxx/db.hpp 2014-07-25 17:46:09 +0900 (de7fb4c) @@ -1,8 +1,7 @@ #ifndef GRNXX_DB_HPP #define GRNXX_DB_HPP -#include <vector> - +#include "grnxx/array.hpp" #include "grnxx/types.hpp" namespace grnxx { @@ -87,7 +86,7 @@ class DB { const DBOptions &options = DBOptions()) const; private: - std::vector<unique_ptr<Table>> tables_; + Array<unique_ptr<Table>> tables_; DB(); Modified: lib/grnxx/db.cpp (+3 -6) =================================================================== --- lib/grnxx/db.cpp 2014-07-25 17:40:12 +0900 (eadd2b7) +++ lib/grnxx/db.cpp 2014-07-25 17:46:09 +0900 (15884e1) @@ -16,10 +16,7 @@ Table *DB::create_table(Error *error, static_cast<int>(name.size()), name.data()); return nullptr; } - try { - tables_.reserve(tables_.size() + 1); - } catch (...) { - GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed"); + if (!tables_.reserve(error, tables_.size() + 1)) { return nullptr; } unique_ptr<Table> new_table = @@ -27,7 +24,7 @@ Table *DB::create_table(Error *error, if (!new_table) { return nullptr; } - tables_.push_back(std::move(new_table)); + tables_.push_back(error, std::move(new_table)); return tables_.back().get(); } @@ -42,7 +39,7 @@ bool DB::remove_table(Error *error, String name) { static_cast<int>(name.size()), name.data()); return false; } - tables_.erase(tables_.begin() + table_id); + tables_.erase(table_id); return true; } -------------- next part -------------- HTML����������������������������...Download