diff libinterp/parse-tree/pt-mat.cc @ 27371:fcaecdbc8d8a

don't use visitor pattern for expression evaluation (bug #56752) Although it is desirable to have all parse tree evaluation functions grouped together in a single file, using the visitor pattern can be inefficient, especially when the visitor function is small and the extra levels of indirection and virtual function resolution can take more time than the evaluation function itself (evaluation of constants, for example). For all classes derived from tree_expression, introduce new evaluate and evaluate_n methods. Use those instead of visit_CLASS functions to perform expression evaluation. Results are now returned directly from the evaluation functions instead of storing them in the tree_evaluator object. Files affected: cdef-class.cc, oct-parse.yy, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-classdef.cc, pt-classdef.h, pt-colon.cc, pt-colon.h, pt-const.h, pt-eval.cc, pt-eval.h, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-loop.cc, pt-mat.cc, pt-mat.h, pt-select.cc, pt-tm-const.cc, pt-unop.cc, and pt-unop.h.
author John W. Eaton <jwe@octave.org>
date Fri, 30 Aug 2019 15:02:14 -0400
parents bb8d66018bd7
children b442ec6dda5c
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-mat.cc	Wed Aug 28 21:38:34 2019 -0400
+++ b/libinterp/parse-tree/pt-mat.cc	Fri Aug 30 15:02:14 2019 -0400
@@ -25,11 +25,13 @@
 #endif
 
 #include "defun.h"
+#include "ov.h"
 #include "ovl.h"
 #include "pt-arg-list.h"
+#include "pt-eval.h"
 #include "pt-exp.h"
 #include "pt-mat.h"
-#include "ov.h"
+#include "pt-tm-const.h"
 #include "variables.h"
 
 #include "ov-cx-mat.h"
@@ -39,6 +41,14 @@
 
 namespace octave
 {
+  octave_value
+  tree_matrix::evaluate (tree_evaluator& tw, int)
+  {
+    tm_const tmp (*this, tw);
+
+    return tmp.concat (tw.string_fill_char ());
+  }
+
   std::string
   get_concat_class (const std::string& c1, const std::string& c2)
   {