[Groonga-commit] groonga/grnxx at 63ba074 [master] Remove an argument "error" from DB::get_table().

Back to archive index

susumu.yata null+****@clear*****
Fri Jul 4 18:11:13 JST 2014


susumu.yata	2014-07-04 18:11:13 +0900 (Fri, 04 Jul 2014)

  New Revision: 63ba074446241e70d3feaebac7279cfe2a0fbb09
  https://github.com/groonga/grnxx/commit/63ba074446241e70d3feaebac7279cfe2a0fbb09

  Message:
    Remove an argument "error" from DB::get_table().

  Modified files:
    include/grnxx/db.hpp
    lib/grnxx/db.cpp
    test/test_grnxx.cpp

  Modified: include/grnxx/db.hpp (+5 -1)
===================================================================
--- include/grnxx/db.hpp    2014-07-04 17:58:58 +0900 (7d3583b)
+++ include/grnxx/db.hpp    2014-07-04 18:11:13 +0900 (562e3a6)
@@ -62,10 +62,14 @@ class DB {
 
   // Get a table identified by "table_id".
   //
+  // If "table_id" is invalid, the result is undefined.
+  //
   // Returns a pointer to the table on success.
   // On failure, returns nullptr and stores error information into "*error" if
   // "error" != nullptr.
-  Table *get_table(Error *error, size_t table_id) const;
+  Table *get_table(size_t table_id) const {
+    return tables_[table_id].get();
+  }
 
   // Find a table named "name".
   //

  Modified: lib/grnxx/db.cpp (+0 -9)
===================================================================
--- lib/grnxx/db.cpp    2014-07-04 17:58:58 +0900 (d100cd9)
+++ lib/grnxx/db.cpp    2014-07-04 18:11:13 +0900 (a77c7d1)
@@ -93,15 +93,6 @@ bool DB::reorder_table(Error *error,
   return true;
 }
 
-Table *DB::get_table(Error *error, size_t table_id) const {
-  if (table_id >= num_tables()) {
-    GRNXX_ERROR_SET(error, NOT_FOUND,
-                    "Table not found: table_id = %" PRIi64, table_id);
-    return nullptr;
-  }
-  return tables_[table_id].get();
-}
-
 Table *DB::find_table(Error *error, String name) const {
   for (size_t table_id = 0; table_id < num_tables(); ++table_id) {
     if (name == tables_[table_id]->name()) {

  Modified: test/test_grnxx.cpp (+12 -12)
===================================================================
--- test/test_grnxx.cpp    2014-07-04 17:58:58 +0900 (cde8282)
+++ test/test_grnxx.cpp    2014-07-04 18:11:13 +0900 (2842036)
@@ -37,7 +37,7 @@ void test_db() {
   assert(table->name() == "Table_1");
   assert(db->num_tables() == 1);
 
-  assert(db->get_table(&error, 0) == table);
+  assert(db->get_table(0) == table);
   assert(db->find_table(&error, "Table_1") == table);
 
   assert(!db->create_table(&error, "Table_1", grnxx::TableOptions()));
@@ -49,25 +49,25 @@ void test_db() {
   assert(db->remove_table(&error, "Table_2"));
   assert(db->num_tables() == 2);
 
-  assert(db->get_table(&error, 0)->name() == "Table_1");
-  assert(db->get_table(&error, 1)->name() == "Table_3");
+  assert(db->get_table(0)->name() == "Table_1");
+  assert(db->get_table(1)->name() == "Table_3");
 
   assert(db->create_table(&error, "Table_2", grnxx::TableOptions()));
 
   assert(db->reorder_table(&error, "Table_3", "Table_2"));
-  assert(db->get_table(&error, 0)->name() == "Table_1");
-  assert(db->get_table(&error, 1)->name() == "Table_2");
-  assert(db->get_table(&error, 2)->name() == "Table_3");
+  assert(db->get_table(0)->name() == "Table_1");
+  assert(db->get_table(1)->name() == "Table_2");
+  assert(db->get_table(2)->name() == "Table_3");
 
   assert(db->reorder_table(&error, "Table_3", ""));
-  assert(db->get_table(&error, 0)->name() == "Table_3");
-  assert(db->get_table(&error, 1)->name() == "Table_1");
-  assert(db->get_table(&error, 2)->name() == "Table_2");
+  assert(db->get_table(0)->name() == "Table_3");
+  assert(db->get_table(1)->name() == "Table_1");
+  assert(db->get_table(2)->name() == "Table_2");
 
   assert(db->reorder_table(&error, "Table_2", "Table_3"));
-  assert(db->get_table(&error, 0)->name() == "Table_3");
-  assert(db->get_table(&error, 1)->name() == "Table_2");
-  assert(db->get_table(&error, 2)->name() == "Table_1");
+  assert(db->get_table(0)->name() == "Table_3");
+  assert(db->get_table(1)->name() == "Table_2");
+  assert(db->get_table(2)->name() == "Table_1");
 }
 
 void test_table() {
-------------- next part --------------
HTML����������������������������...
Download 



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