Mercurial > octave
comparison libinterp/octave-value/ov-base.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 | 670a0d878af1 |
children | e88a07dec498 |
comparison
equal
deleted
inserted
replaced
31259:e39634a768e7 | 31260:c5c8bf50449c |
---|---|
897 | 897 |
898 string_vector | 898 string_vector |
899 octave_base_value::map_keys (void) const | 899 octave_base_value::map_keys (void) const |
900 { | 900 { |
901 err_wrong_type_arg ("octave_base_value::map_keys()", type_name ()); | 901 err_wrong_type_arg ("octave_base_value::map_keys()", type_name ()); |
902 } | |
903 | |
904 bool | |
905 octave_base_value::isfield (const std::string&) const | |
906 { | |
907 err_wrong_type_arg ("octave_base_value::isfield()", type_name ()); | |
902 } | 908 } |
903 | 909 |
904 std::size_t | 910 std::size_t |
905 octave_base_value::nparents (void) const | 911 octave_base_value::nparents (void) const |
906 { | 912 { |