changeset 13959:cf8cd43cdeb3

cellfun: further optimisations for the string vs function handle cases
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 29 Nov 2011 11:23:41 -0500
parents cb15c5185b6a
children ef96344a6e58
files src/DLD-FUNCTIONS/cellfun.cc
diffstat 1 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/cellfun.cc	Tue Nov 29 04:42:16 2011 -0500
+++ b/src/DLD-FUNCTIONS/cellfun.cc	Tue Nov 29 11:23:41 2011 -0500
@@ -447,10 +447,28 @@
               if (f -> is_overloaded ())
                 goto nevermind;
             }
-          octave_value f = symbol_table::find_function (func.function_value ()
-                                                         -> name ());
+
+          std::string name = func.function_value () -> name ();
+          octave_value f = symbol_table::find_function (name);
+
           if (f.is_defined ())
-            func = f;
+            {
+              //Except for these two which are special cases...
+              if (name != "size" && name != "class")
+                {
+                  //Try first the optimised code path for built-in functions
+                  octave_value_list tmp_args = args;
+                  tmp_args(0) = name;
+                  retval = try_cellfun_internal_ops (tmp_args, nargin);
+                  if (error_state || ! retval.empty ())
+                    return retval;
+                }
+
+              //Okay, we tried, doesn't work, let's do the best we can
+              //instead and avoid polymorphic calls for each element of
+              //the array.
+              func = f;
+            }
         }
 
     nevermind: