From 93eaccae6fe6e8442a3c6e5a2d40a408aa44df77 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" <graham@lindenlab.com> Date: Thu, 28 Feb 2013 15:35:14 -0800 Subject: [PATCH] Modify LLInstanceTracker to avoid using a map of strings to find a map of foo to find some pointers --- doc/contributions.txt | 1 + indra/llcommon/lleventapi.h | 5 +-- indra/llcommon/lleventtimer.h | 3 +- indra/llcommon/llfasttimer.h | 5 +-- indra/llcommon/llinstancetracker.cpp | 14 +++----- indra/llcommon/llinstancetracker.h | 46 +++++++++++++++++++++------ indra/llcommon/llleap.h | 3 +- indra/llrender/llgl.h | 4 +-- indra/llui/llconsole.h | 3 +- indra/llui/llfloater.h | 5 ++- indra/llui/lllayoutstack.h | 3 +- indra/llui/llnotifications.h | 5 +-- indra/llwindow/llwindow.h | 3 +- indra/llxml/llcontrol.cpp | 2 +- indra/llxml/llcontrol.h | 10 +++--- indra/newview/lldrawable.cpp | 6 ++++ indra/newview/llfloaterwebcontent.cpp | 2 +- indra/newview/llfloaterwebcontent.h | 5 +-- indra/newview/llmediactrl.cpp | 2 +- indra/newview/llmediactrl.h | 3 +- indra/newview/llnamelistctrl.h | 3 +- indra/newview/lltoast.cpp | 2 +- indra/newview/lltoast.h | 3 +- 23 files changed, 91 insertions(+), 47 deletions(-) diff --git a/doc/contributions.txt b/doc/contributions.txt index f2c249c7c1d..33b2ded81db 100644 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -750,6 +750,7 @@ Marine Kelley MartinRJ Fayray STORM-1844 STORM-1845 + STORM-1934 Matthew Anthony Matthew Dowd VWR-1344 diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h index 1a37d780b63..10c7e7a23f3 100644 --- a/indra/llcommon/lleventapi.h +++ b/indra/llcommon/lleventapi.h @@ -41,12 +41,13 @@ * Deriving from LLInstanceTracker lets us enumerate instances. */ class LL_COMMON_API LLEventAPI: public LLDispatchListener, - public LLInstanceTracker<LLEventAPI, std::string> + public INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) { typedef LLDispatchListener lbase; - typedef LLInstanceTracker<LLEventAPI, std::string> ibase; + typedef INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) ibase; public: + /** * @param name LLEventPump name on which this LLEventAPI will listen. This * also serves as the LLInstanceTracker instance key. diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h index 7f42623d017..e55f851758b 100644 --- a/indra/llcommon/lleventtimer.h +++ b/indra/llcommon/lleventtimer.h @@ -33,9 +33,10 @@ #include "lltimer.h" // class for scheduling a function to be called at a given frequency (approximate, inprecise) -class LL_COMMON_API LLEventTimer : public LLInstanceTracker<LLEventTimer> +class LL_COMMON_API LLEventTimer : public INSTANCE_TRACKER(LLEventTimer) { public: + LLEventTimer(F32 period); // period is the amount of time between each call to tick() in seconds LLEventTimer(const LLDate& time); virtual ~LLEventTimer(); diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e42e549df58..440d42ab5ac 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -63,7 +63,7 @@ class LL_COMMON_API LLFastTimer // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances class LL_COMMON_API NamedTimer - : public LLInstanceTracker<NamedTimer> + : public LLInstanceTracker<NamedTimer, InstanceTrackType_NamedTimer > { friend class DeclareTimer; public: @@ -137,10 +137,11 @@ class LL_COMMON_API LLFastTimer // used to statically declare a new named timer class LL_COMMON_API DeclareTimer - : public LLInstanceTracker<DeclareTimer> + : public LLInstanceTracker< DeclareTimer, InstanceTrackType_DeclareTimer > { friend class LLFastTimer; public: + DeclareTimer(const std::string& name, bool open); DeclareTimer(const std::string& name); diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 5dc3ea5d7bc..0804be358f2 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -32,18 +32,14 @@ // external library headers // other Linden headers -//static -void * & LLInstanceTrackerBase::getInstances(std::type_info const & info) -{ - typedef std::map<std::string, void *> InstancesMap; - static InstancesMap instances; +static void* sInstanceTrackerData[ kInstanceTrackTypeCount ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t) +{ // std::map::insert() is just what we want here. You attempt to insert a // (key, value) pair. If the specified key doesn't yet exist, it inserts // the pair and returns a std::pair of (iterator, true). If the specified // key DOES exist, insert() simply returns (iterator, false). One lookup // handles both cases. - return instances.insert(InstancesMap::value_type(info.name(), - InstancesMap::mapped_type())) - .first->second; -} + return sInstanceTrackerData[t]; +} \ No newline at end of file diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 403df08990e..70bccde9929 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -38,6 +38,31 @@ #include <boost/iterator/transform_iterator.hpp> #include <boost/iterator/indirect_iterator.hpp> +enum InstanceTrackType +{ + InstanceTrackType_LLEventAPI, + InstanceTrackType_LLEventTimer, + InstanceTrackType_NamedTimer, + InstanceTrackType_DeclareTimer, + InstanceTrackType_LLLeap, + InstanceTrackType_LLGLNamePool, + InstanceTrackType_LLConsole, + InstanceTrackType_LLFloater, + InstanceTrackType_LLFloaterWebContent, + InstanceTrackType_LLLayoutStack, + InstanceTrackType_LLNotificationContext, + InstanceTrackType_LLWindow, + InstanceTrackType_LLControlGroup, + InstanceTrackType_LLControlCache, + InstanceTrackType_LLMediaCtrl, + InstanceTrackType_LLNameListCtrl, + InstanceTrackType_LLToast, + kInstanceTrackTypeCount +}; + +#define INSTANCE_TRACKER(T) LLInstanceTracker< T, InstanceTrackType_##T > +#define INSTANCE_TRACKER_KEYED(T,K) LLInstanceTracker< T, InstanceTrackType_##T, K > + /** * Base class manages "class-static" data that must actually have singleton * semantics: one instance per process, rather than one instance per module as @@ -47,14 +72,15 @@ class LL_COMMON_API LLInstanceTrackerBase : public boost::noncopyable { protected: /// Get a process-unique void* pointer slot for the specified type_info - static void * & getInstances(std::type_info const & info); + //static void * & getInstances(std::type_info const & info); + static void * & getInstances(InstanceTrackType t); /// Find or create a STATICDATA instance for the specified TRACKED class. /// STATICDATA must be default-constructible. - template<typename STATICDATA, class TRACKED> + template<typename STATICDATA, class TRACKED, class INST, InstanceTrackType TRACKEDTYPE> static STATICDATA& getStatic() { - void *& instances = getInstances(typeid(TRACKED)); + void *& instances = getInstances(TRACKEDTYPE); if (! instances) { instances = new STATICDATA; @@ -78,16 +104,16 @@ class LL_COMMON_API LLInstanceTrackerBase : public boost::noncopyable /// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup /// If KEY is not provided, then instances are stored in a simple set /// @NOTE: see explicit specialization below for default KEY==T* case -template<typename T, typename KEY = T*> +template<typename T, enum InstanceTrackType TRACKED, typename KEY = T*> class LLInstanceTracker : public LLInstanceTrackerBase { - typedef LLInstanceTracker<T, KEY> MyT; + typedef LLInstanceTracker<T, TRACKED, KEY> MyT; typedef typename std::map<KEY, T*> InstanceMap; struct StaticData: public StaticBase { InstanceMap sMap; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT>(); } + static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT, T, TRACKED>(); } static InstanceMap& getMap_() { return getStatic().sMap; } public: @@ -226,16 +252,16 @@ class LLInstanceTracker : public LLInstanceTrackerBase /// explicit specialization for default case where KEY is T* /// use a simple std::set<T*> -template<typename T> -class LLInstanceTracker<T, T*> : public LLInstanceTrackerBase +template<typename T, enum InstanceTrackType TRACKED> +class LLInstanceTracker<T, TRACKED, T*> : public LLInstanceTrackerBase { - typedef LLInstanceTracker<T, T*> MyT; + typedef LLInstanceTracker<T, TRACKED, T*> MyT; typedef typename std::set<T*> InstanceSet; struct StaticData: public StaticBase { InstanceSet sSet; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT>(); } + static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT, T, TRACKED>(); } static InstanceSet& getSet_() { return getStatic().sSet; } public: diff --git a/indra/llcommon/llleap.h b/indra/llcommon/llleap.h index 1a1ad23d392..d4e138f4be8 100644 --- a/indra/llcommon/llleap.h +++ b/indra/llcommon/llleap.h @@ -29,9 +29,10 @@ * LLLeap* pointer should be validated before use by * LLLeap::getInstance(LLLeap*) (see LLInstanceTracker). */ -class LL_COMMON_API LLLeap: public LLInstanceTracker<LLLeap> +class LL_COMMON_API LLLeap: public INSTANCE_TRACKER(LLLeap) { public: + /** * Pass a brief string description, mostly for logging purposes. The desc * need not be unique, but obviously the clearer we can make it, the diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 823de9d3614..133c2de1f5a 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -350,10 +350,10 @@ class LLGLSquashToFarClip Generic pooling scheme for things which use GL names (used for occlusion queries and vertex buffer objects). Prevents thrashing of GL name caches by avoiding calls to glGenFoo and glDeleteFoo. */ -class LLGLNamePool : public LLInstanceTracker<LLGLNamePool> +class LLGLNamePool : public INSTANCE_TRACKER(LLGLNamePool) { public: - typedef LLInstanceTracker<LLGLNamePool> tracker_t; + typedef INSTANCE_TRACKER(LLGLNamePool) tracker_t; struct NameEntry { diff --git a/indra/llui/llconsole.h b/indra/llui/llconsole.h index f32f1dd74c3..b264aeb7eb9 100644 --- a/indra/llui/llconsole.h +++ b/indra/llui/llconsole.h @@ -34,9 +34,10 @@ class LLSD; -class LLConsole : public LLFixedBuffer, public LLUICtrl, public LLInstanceTracker<LLConsole> +class LLConsole : public LLFixedBuffer, public LLUICtrl, public INSTANCE_TRACKER(LLConsole) { public: + typedef enum e_font_size { MONOSPACE = -1, diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index aef63bcf936..113fdf10e4f 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -112,15 +112,18 @@ struct LLCoordFloater : LLCoord<LL_COORD_FLOATER> bool operator!=(const LLCoordFloater& other) const { return !(*this == other); } void setFloater(LLFloater& floater); + + }; -class LLFloater : public LLPanel, public LLInstanceTracker<LLFloater> +class LLFloater : public LLPanel, public INSTANCE_TRACKER(LLFloater) { friend class LLFloaterView; friend class LLFloaterReg; friend class LLMultiFloater; public: + struct KeyCompare { // static bool compare(const LLSD& a, const LLSD& b); diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 648cd5fdce2..26b8a7f9734 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -34,9 +34,10 @@ class LLLayoutPanel; -class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack> +class LLLayoutStack : public LLView, public INSTANCE_TRACKER(LLLayoutStack) { public: + typedef enum e_layout_orientation { HORIZONTAL, diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index d7534c416dc..faeba8f6eb7 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -136,10 +136,11 @@ typedef LLFunctorRegistration<LLNotificationResponder> LLNotificationFunctorRegi // context data that can be looked up via a notification's payload by the display logic // derive from this class to implement specific contexts -class LLNotificationContext : public LLInstanceTracker<LLNotificationContext, LLUUID> +class LLNotificationContext : public INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID) { public: - LLNotificationContext() : LLInstanceTracker<LLNotificationContext, LLUUID>(LLUUID::generateNewID()) + + LLNotificationContext() : INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID)(LLUUID::generateNewID()) { } diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index e9147d552e1..06d7e4907af 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -39,9 +39,10 @@ class LLWindowCallbacks; // Refer to llwindow_test in test/common/llwindow for usage example -class LLWindow : public LLInstanceTracker<LLWindow> +class LLWindow : public INSTANCE_TRACKER(LLWindow) { public: + struct LLWindowResolution { S32 mWidth; diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 53d9380f4f8..561f4fdc73c 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -316,7 +316,7 @@ LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name) //////////////////////////////////////////////////////////////////////////// LLControlGroup::LLControlGroup(const std::string& name) -: LLInstanceTracker<LLControlGroup, std::string>(name) +: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { mTypeString[TYPE_U32] = "U32"; mTypeString[TYPE_S32] = "S32"; diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index ee7d1d50b7e..6ea010f4f9f 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -180,7 +180,7 @@ T convert_from_llsd(const LLSD& sd, eControlType type, const std::string& contro } //const U32 STRING_CACHE_SIZE = 10000; -class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string> +class LLControlGroup : public INSTANCE_TRACKER_KEYED(LLControlGroup, std::string) { LOG_CLASS(LLControlGroup); @@ -197,7 +197,7 @@ class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string> ~LLControlGroup(); void cleanup(); - typedef LLInstanceTracker<LLControlGroup, std::string>::instance_iter instance_iter; + typedef INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)::instance_iter instance_iter; LLControlVariablePtr getControl(const std::string& name); @@ -306,7 +306,7 @@ class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string> //! without have to manually create and bind a listener to a local //! object. template <class T> -class LLControlCache : public LLRefCount, public LLInstanceTracker<LLControlCache<T>, std::string> +class LLControlCache : public LLRefCount, public LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string> { public: // This constructor will declare a control if it doesn't exist in the contol group @@ -314,7 +314,7 @@ class LLControlCache : public LLRefCount, public LLInstanceTracker<LLControlCach const std::string& name, const T& default_value, const std::string& comment) - : LLInstanceTracker<LLControlCache<T>, std::string >(name) + : LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string >(name) { if(!group.controlExists(name)) { @@ -329,7 +329,7 @@ class LLControlCache : public LLRefCount, public LLInstanceTracker<LLControlCach LLControlCache(LLControlGroup& group, const std::string& name) - : LLInstanceTracker<LLControlCache<T>, std::string >(name) + : LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string >(name) { if(!group.controlExists(name)) { diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index d041baea901..119b8d24d04 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -577,6 +577,12 @@ F32 LLDrawable::updateXform(BOOL undamped) mVObjp->dirtySpatialGroup(); } } + else if (!isRoot() + && ( dist_vec_squared(old_pos, target_pos) > 0.f + || (1.f - dot(old_rot, target_rot)) > 0.f)) + { // update child prims moved from LSL + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } else if (!getVOVolume() && !isAvatar()) { movePartition(); diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index 3fe2518de67..94c3f4149c7 100644 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -54,7 +54,7 @@ LLFloaterWebContent::_Params::_Params() LLFloaterWebContent::LLFloaterWebContent( const Params& params ) : LLFloater( params ), - LLInstanceTracker<LLFloaterWebContent, std::string>(params.id()), + INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string)(params.id()), mWebBrowser(NULL), mAddressCombo(NULL), mSecureLockIcon(NULL), diff --git a/indra/newview/llfloaterwebcontent.h b/indra/newview/llfloaterwebcontent.h index cfc87e90155..409c15fb0b4 100644 --- a/indra/newview/llfloaterwebcontent.h +++ b/indra/newview/llfloaterwebcontent.h @@ -40,10 +40,11 @@ class LLIconCtrl; class LLFloaterWebContent : public LLFloater, public LLViewerMediaObserver, - public LLInstanceTracker<LLFloaterWebContent, std::string> + public INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string) { public: - typedef LLInstanceTracker<LLFloaterWebContent, std::string> instance_tracker_t; + + typedef INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string) instance_tracker_t; LOG_CLASS(LLFloaterWebContent); struct _Params : public LLInitParam::Block<_Params> diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 99b4707158f..48730f0f207 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -81,7 +81,7 @@ LLMediaCtrl::Params::Params() LLMediaCtrl::LLMediaCtrl( const Params& p) : LLPanel( p ), - LLInstanceTracker<LLMediaCtrl, LLUUID>(LLUUID::generateNewID()), + INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID)(LLUUID::generateNewID()), mTextureDepthBytes( 4 ), mBorder(NULL), mFrequentUpdates( true ), diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index 7f2a5e16427..4fed21bf225 100644 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -42,10 +42,11 @@ class LLMediaCtrl : public LLPanel, public LLViewerMediaObserver, public LLViewerMediaEventEmitter, - public LLInstanceTracker<LLMediaCtrl, LLUUID> + public INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID) { LOG_CLASS(LLMediaCtrl); public: + struct Params : public LLInitParam::Block<Params, LLPanel::Params> { Optional<std::string> start_url; diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h index 09c3d49fe73..103806a1bd7 100644 --- a/indra/newview/llnamelistctrl.h +++ b/indra/newview/llnamelistctrl.h @@ -64,9 +64,10 @@ class LLNameListItem : public LLScrollListItem, public LLHandleProvider<LLNameLi class LLNameListCtrl -: public LLScrollListCtrl, public LLInstanceTracker<LLNameListCtrl> +: public LLScrollListCtrl, public INSTANCE_TRACKER(LLNameListCtrl) { public: + typedef enum e_name_type { INDIVIDUAL, diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index 9dfb29b905c..49debe67f6e 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -572,7 +572,7 @@ S32 LLToast::notifyParent(const LLSD& info) //static void LLToast::updateClass() { - for (LLInstanceTracker<LLToast>::instance_iter iter = LLInstanceTracker<LLToast>::beginInstances(); iter != LLInstanceTracker<LLToast>::endInstances(); ) + for (INSTANCE_TRACKER(LLToast)::instance_iter iter = INSTANCE_TRACKER(LLToast)::beginInstances(); iter != INSTANCE_TRACKER(LLToast)::endInstances(); ) { LLToast& toast = *iter++; diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index e1d99b1bcba..8f77e7b78b2 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -69,10 +69,11 @@ private : * Represents toast pop-up. * This is a parent view for all toast panels. */ -class LLToast : public LLModalDialog, public LLInstanceTracker<LLToast> +class LLToast : public LLModalDialog, public INSTANCE_TRACKER(LLToast) { friend class LLToastLifeTimer; public: + typedef boost::function<void (LLToast* toast)> toast_callback_t; typedef boost::signals2::signal<void (LLToast* toast)> toast_signal_t; typedef boost::signals2::signal<void (LLToast* toast, bool mouse_enter)> toast_hover_check_signal_t; -- GitLab