comparison libinterp/octave-value/ov-struct.cc @ 31260:c5c8bf50449c

Improve performance of isfield from linear time to constant time (bug #58105) Patch author: Anonymous in Bug #58105 Comment #7 https://savannah.gnu.org/bugs/index.php?58105#comment7 The isfield function was taking time proportional to the number of fields in a struct to determine whether something was a member or not. With this change, isfield performance becomes constant irrespective of the number of fields, speeding up performance by over 200X, and also allowing the use of struct as a hashmap if the user desires. ov-base.h: Add new isfield function declaration ov-base.cc: Add new isfield function definition ov-struct.h: Add new isfield function definitions ov-struct.cc: Do not call map_value ov.h: Add new isfield function definition
author Arun Giridhar <arungiridhar@gmail.com>
date Wed, 05 Oct 2022 10:35:31 -0400
parents 32d2b6604a9f
children e88a07dec498
comparison
equal deleted inserted replaced
31259:e39634a768e7 31260:c5c8bf50449c
1949 1949
1950 octave_value retval = false; 1950 octave_value retval = false;
1951 1951
1952 if (args(0).isstruct ()) 1952 if (args(0).isstruct ())
1953 { 1953 {
1954 octave_map m = args(0).map_value (); 1954 octave_value m = args(0);
1955 1955
1956 // FIXME: should this work for all types that can do 1956 // FIXME: should this work for all types that can do
1957 // structure reference operations? 1957 // structure reference operations?
1958 if (args(1).is_string ()) 1958 if (args(1).is_string ())
1959 { 1959 {