# HG changeset patch # User Rik # Date 1442911120 25200 # Node ID bf6c4433ed5f1a9a408659a6b243d2cc8363fe1c # Parent fbbdd14aa7cea3cb36639704ddf6bfc3d3c7c62f Clean up isa() function. * ov-class.cc (Fisa): Remove not strictly necessary const modifiers on variables. Use more meaningful variable names. Put direct test for class name first in if tree since this is the most likely test to succeed. diff -r fbbdd14aa7ce -r bf6c4433ed5f libinterp/octave-value/ov-class.cc --- a/libinterp/octave-value/ov-class.cc Mon Sep 21 17:56:03 2015 +0200 +++ b/libinterp/octave-value/ov-class.cc Tue Sep 22 01:38:40 2015 -0700 @@ -1985,23 +1985,24 @@ return retval; } - octave_value obj = args(0); // not const because of find_parent_class () - const Array cls = args(1).cellstr_value (); + octave_value obj = args(0); // not const because of find_parent_class () + std::string obj_cls = obj.class_name (); + Array clsnames = args(1).cellstr_value (); if (error_state) { error ("isa: CLASSNAME must be a string or cell array of strings"); return retval; } - boolNDArray matches (cls.dims (), false); - const octave_idx_type n = cls.numel (); - for (octave_idx_type idx = 0; idx < n; idx++) + boolNDArray matches (clsnames.dims (), false); + for (octave_idx_type idx = 0; idx < clsnames.numel (); idx++) { - const std::string cl = cls(idx); - if ((cl == "float" && obj.is_float_type ()) - || (cl == "integer" && obj.is_integer_type ()) - || (cl == "numeric" && obj.is_numeric_type ()) - || obj.class_name () == cl || obj.is_instance_of (cl)) + std::string cls = clsnames(idx); + if (obj_cls == cls + || (cls == "float" && obj.is_float_type ()) + || (cls == "integer" && obj.is_integer_type ()) + || (cls == "numeric" && obj.is_numeric_type ()) + || obj.is_instance_of (cls)) matches(idx) = true; } return octave_value (matches);