[Groonga-commit] groonga/grnxx at 9c175be [master] Update RecordSet to use Array.

Back to archive index

susumu.yata null+****@clear*****
Fri Jul 25 17:58:48 JST 2014


susumu.yata	2014-07-25 17:58:48 +0900 (Fri, 25 Jul 2014)

  New Revision: 9c175be2ecf140cf6a3afeecec7aeb56c22fc245
  https://github.com/groonga/grnxx/commit/9c175be2ecf140cf6a3afeecec7aeb56c22fc245

  Message:
    Update RecordSet to use Array.

  Modified files:
    include/grnxx/record.hpp
    lib/grnxx/record.cpp

  Modified: include/grnxx/record.hpp (+4 -21)
===================================================================
--- include/grnxx/record.hpp    2014-07-25 17:56:27 +0900 (c826d1a)
+++ include/grnxx/record.hpp    2014-07-25 17:58:48 +0900 (32858b1)
@@ -1,8 +1,7 @@
 #ifndef GRNXX_RECORD_HPP
 #define GRNXX_RECORD_HPP
 
-#include <vector>
-
+#include "grnxx/array.hpp"
 #include "grnxx/types.hpp"
 
 namespace grnxx {
@@ -15,7 +14,6 @@ struct Record {
   Record(Int row_id, Float score) : row_id(row_id), score(score) {}
 };
 
-// TODO: RecordSet should be reimplemented not to use std::vector?
 class RecordSet {
  public:
   RecordSet() : records_() {}
@@ -32,13 +30,7 @@ class RecordSet {
   // On failure, returns false and stores error information into "*error" if
   // "error" != nullptr.
   bool append(Error *error, const Record &record) {
-    try {
-      records_.push_back(record);
-      return true;
-    } catch (...) {
-      report_error(error);
-      return false;
-    }
+    return records_.push_back(error, record);
   }
 
   // Return the record identified by "i".
@@ -61,13 +53,7 @@ class RecordSet {
   // On failure, returns false and stores error information into "*error" if
   // "error" != nullptr.
   bool resize(Error *error, Int size) {
-    try {
-      records_.resize(size);
-      return true;
-    } catch (...) {
-      report_error(error);
-      return false;
-    }
+    return records_.resize(error, size);
   }
 
   // Clear all the records.
@@ -76,10 +62,7 @@ class RecordSet {
   }
 
  private:
-  std::vector<Record> records_;
-
-  // Report a no memory error.
-  void report_error(Error *error);
+  Array<Record> records_;
 };
 
 }  // namespace grnxx

  Modified: lib/grnxx/record.cpp (+1 -3)
===================================================================
--- lib/grnxx/record.cpp    2014-07-25 17:56:27 +0900 (929aea7)
+++ lib/grnxx/record.cpp    2014-07-25 17:58:48 +0900 (e7dda5d)
@@ -4,8 +4,6 @@
 
 namespace grnxx {
 
-void RecordSet::report_error(Error *error) {
-  GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed");
-}
+// TODO: RecordSet should be replaced with Array<Record>?
 
 }  // namespace
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index