susumu.yata
null+****@clear*****
Mon Jul 28 11:09:11 JST 2014
susumu.yata 2014-07-28 11:09:11 +0900 (Mon, 28 Jul 2014) New Revision: 2bec5c55599f2a9c3134e58dcd7242f2d28dbf30 https://github.com/groonga/grnxx/commit/2bec5c55599f2a9c3134e58dcd7242f2d28dbf30 Message: Update Column to use Array. Modified files: lib/grnxx/column.cpp lib/grnxx/column_impl.hpp Modified: lib/grnxx/column.cpp (+5 -19) =================================================================== --- lib/grnxx/column.cpp 2014-07-28 11:06:46 +0900 (1179d17) +++ lib/grnxx/column.cpp 2014-07-28 11:09:11 +0900 (093e2c9) @@ -185,11 +185,8 @@ unique_ptr<ColumnImpl<T>> ColumnImpl<T>::create(Error *error, TypeTraits<T>::data_type(), options)) { return nullptr; } - try { - column->values_.resize(table->max_row_id() + 1, - TypeTraits<T>::default_value()); - } catch (...) { - GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed"); + if (!column->values_.resize(error, table->max_row_id() + 1, + TypeTraits<T>::default_value())) { return nullptr; } return column; @@ -201,11 +198,7 @@ ColumnImpl<T>::~ColumnImpl() {} template <typename T> bool ColumnImpl<T>::set_default_value(Error *error, Int row_id) { if (row_id >= values_.size()) { - try { - values_.resize(row_id + 1, TypeTraits<T>::default_value()); - return true; - } catch (...) { - GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed"); + if (!values_.resize(error, row_id + 1, TypeTraits<T>::default_value())) { return false; } } @@ -263,10 +256,7 @@ unique_ptr<ColumnImpl<Text>> ColumnImpl<Text>::create( if (!column->initialize_base(error, table, name, TEXT_DATA, options)) { return nullptr; } - try { - column->values_.resize(table->max_row_id() + 1); - } catch (...) { - GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed"); + if (!column->values_.resize(error, table->max_row_id() + 1)) { return nullptr; } return column; @@ -276,11 +266,7 @@ ColumnImpl<Text>::~ColumnImpl() {} bool ColumnImpl<Text>::set_default_value(Error *error, Int row_id) { if (row_id >= values_.size()) { - try { - values_.resize(row_id + 1); - return true; - } catch (...) { - GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed"); + if (!values_.resize(error, row_id + 1)) { return false; } } Modified: lib/grnxx/column_impl.hpp (+3 -4) =================================================================== --- lib/grnxx/column_impl.hpp 2014-07-28 11:06:46 +0900 (8fb6236) +++ lib/grnxx/column_impl.hpp 2014-07-28 11:09:11 +0900 (5756ffa) @@ -1,8 +1,7 @@ #ifndef GRNXX_COLUMN_BASE_HPP #define GRNXX_COLUMN_BASE_HPP -#include <vector> - +#include "grnxx/array.hpp" #include "grnxx/column.hpp" namespace grnxx { @@ -40,7 +39,7 @@ class ColumnImpl : public Column { } protected: - std::vector<T> values_; + Array<T> values_; ColumnImpl(); }; @@ -79,7 +78,7 @@ class ColumnImpl<Text> : public Column { protected: // TODO: std::string should not be used. - std::vector<std::string> values_; + Array<std::string> values_; ColumnImpl(); }; -------------- next part -------------- HTML����������������������������...Download