From f66578671e1f45707c64bfc81ddda1aa5affe4fe Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sat, 9 Aug 2014 21:57:44 +0200 Subject: [PATCH] Issue 4057: Create Context::here_defined as faster variant of Context::where_defined --- lily/context.cc | 13 +++++++++++++ lily/include/context.hh | 1 + 2 files changed, 14 insertions(+) diff --git a/lily/context.cc b/lily/context.cc index 7077014501..718ef31122 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -459,6 +459,19 @@ Context::where_defined (SCM sym, SCM *value) const return (daddy_context_) ? daddy_context_->where_defined (sym, value) : 0; } +/* Quick variant of where_defined. Checks only the context itself. */ + +bool +Context::here_defined (SCM sym, SCM *value) const +{ +#ifndef NDEBUG + if (profile_property_accesses) + note_property_access (&context_property_lookup_table, sym); +#endif + + return properties_dict ()->try_retrieve (sym, value); +} + /* return SCM_EOL when not found. */ diff --git a/lily/include/context.hh b/lily/include/context.hh index d6cdfde6e4..0595bf8513 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -97,6 +97,7 @@ public: SCM internal_get_property (SCM name_sym) const; SCM properties_as_alist () const; Context *where_defined (SCM name_sym, SCM *value) const; + bool here_defined (SCM name_sym, SCM *value) const; void unset_property (SCM var_sym); void instrumented_set_property (SCM, SCM, const char *, int, const char *); -- 2.39.5