[Groonga-commit] groonga/grnxx at e68708f [master] Use pass-by-reference for RecordSubset in Expression::adjust().

Back to archive index

susumu.yata null+****@clear*****
Fri Aug 1 16:08:27 JST 2014


susumu.yata	2014-08-01 16:08:27 +0900 (Fri, 01 Aug 2014)

  New Revision: e68708f4a7330ddde45e92d39cda4cac0b68c268
  https://github.com/groonga/grnxx/commit/e68708f4a7330ddde45e92d39cda4cac0b68c268

  Message:
    Use pass-by-reference for RecordSubset in Expression::adjust().

  Modified files:
    lib/grnxx/expression.cpp

  Modified: lib/grnxx/expression.cpp (+9 -8)
===================================================================
--- lib/grnxx/expression.cpp    2014-08-01 16:06:53 +0900 (3dfad1e)
+++ lib/grnxx/expression.cpp    2014-08-01 16:08:27 +0900 (71fbd8b)
@@ -49,7 +49,7 @@ class ExpressionNode {
   // Returns true on success.
   // On failure, returns false and stores error information into "*error" if
   // "error" != nullptr.
-  virtual bool adjust(Error *error, RecordSubset record_set) = 0;
+  virtual bool adjust(Error *error, RecordSubset *record_set) = 0;
 
   // Evaluate the expression subtree.
   //
@@ -74,7 +74,7 @@ class Node : public ExpressionNode {
   }
 
   virtual bool filter(Error *error, RecordSet *record_set);
-  virtual bool adjust(Error *error, RecordSubset record_set);
+  virtual bool adjust(Error *error, RecordSubset *record_set);
 
   virtual bool evaluate(Error *error, const RecordSubset &record_set) = 0;
 
@@ -109,19 +109,19 @@ bool Node<Bool>::filter(Error *error, RecordSet *record_set) {
 }
 
 template <typename T>
-bool Node<T>::adjust(Error *error, RecordSubset record_set) {
+bool Node<T>::adjust(Error *error, RecordSubset *record_set) {
   // Only Node<Float> supports filter().
   GRNXX_ERROR_SET(error, INVALID_OPERATION, "Invalid operation");
   return false;
 }
 
 template <>
-bool Node<Float>::adjust(Error *error, RecordSubset record_set) {
-  if (!evaluate(error, record_set)) {
+bool Node<Float>::adjust(Error *error, RecordSubset *record_set) {
+  if (!evaluate(error, *record_set)) {
     return false;
   }
-  for (Int i = 0; i < record_set.size(); ++i) {
-    record_set.set_score(i, values_[i]);
+  for (Int i = 0; i < record_set->size(); ++i) {
+    record_set->set_score(i, values_[i]);
   }
   return true;
 }
@@ -716,7 +716,8 @@ bool Expression::filter(Error *error, RecordSet *record_set) {
 }
 
 bool Expression::adjust(Error *error, RecordSet *record_set, Int offset) {
-  return root_->adjust(error, record_set->subset(offset));
+  RecordSubset subset = record_set->subset(offset);
+  return root_->adjust(error, &subset);
 }
 
 template <typename T>
-------------- next part --------------
HTML����������������������������...
Download 



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