comparison libinterp/octave-value/ov.h @ 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 eba0a86471b9
children 9a0ce9eea1b7 e88a07dec498
comparison
equal deleted inserted replaced
31259:e39634a768e7 31260:c5c8bf50449c
1068 OCTINTERP_API octave_scalar_map scalar_map_value (void) const; 1068 OCTINTERP_API octave_scalar_map scalar_map_value (void) const;
1069 1069
1070 string_vector map_keys (void) const 1070 string_vector map_keys (void) const
1071 { return m_rep->map_keys (); } 1071 { return m_rep->map_keys (); }
1072 1072
1073 bool isfield (const std::string& field_name) const
1074 { return m_rep->isfield (field_name); }
1075
1073 std::size_t nparents (void) const 1076 std::size_t nparents (void) const
1074 { return m_rep->nparents (); } 1077 { return m_rep->nparents (); }
1075 1078
1076 std::list<std::string> parent_class_name_list (void) const 1079 std::list<std::string> parent_class_name_list (void) const
1077 { return m_rep->parent_class_name_list (); } 1080 { return m_rep->parent_class_name_list (); }