mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-01 18:50:16 +03:00
Reduce heap-allocations on possible hot-paths.
This commit is contained in:
@@ -237,10 +237,10 @@ bool StyleSheetSelector::selectComplex( UIWidget* element, const bool& applyPseu
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<UIWidget*> StyleSheetSelector::getRelatedElements( UIWidget* element,
|
||||
bool applyPseudo ) const {
|
||||
static std::vector<UIWidget*> EMPTY_ELEMENTS;
|
||||
std::vector<UIWidget*> elements;
|
||||
SmallVector<UIWidget*, 8> StyleSheetSelector::getRelatedElements( UIWidget* element,
|
||||
bool applyPseudo ) const {
|
||||
static SmallVector<UIWidget*, 8> EMPTY_ELEMENTS;
|
||||
SmallVector<UIWidget*, 8> elements;
|
||||
if ( mSelectorRules.empty() )
|
||||
return elements;
|
||||
|
||||
|
||||
@@ -1905,4 +1905,10 @@ bool UINode::isCreatingNode() const {
|
||||
return mFlags & UI_CREATING_NODE;
|
||||
}
|
||||
|
||||
void UINode::click() {
|
||||
Vector2f pos;
|
||||
nodeToWorld( pos );
|
||||
getEventDispatcher()->sendMouseClick( this, pos.ceil().asInt(), EE_BUTTON_LMASK );
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -546,12 +546,12 @@ bool UISceneNode::windowExists( UIWindow* win ) {
|
||||
return mWindowsList.end() != std::find( mWindowsList.begin(), mWindowsList.end(), win );
|
||||
}
|
||||
|
||||
std::vector<UIWidget*> UISceneNode::loadNode( pugi::xml_node node, Node* parent,
|
||||
SmallVector<UIWidget*, 8> UISceneNode::loadNode( pugi::xml_node node, Node* parent,
|
||||
const Uint32& marker ) {
|
||||
Uint32 oldMarker = mCurrentMarker;
|
||||
mCurrentMarker = marker;
|
||||
|
||||
std::vector<UIWidget*> rootWidgets;
|
||||
SmallVector<UIWidget*, 8> rootWidgets;
|
||||
|
||||
if ( NULL == parent )
|
||||
parent = this;
|
||||
@@ -646,7 +646,7 @@ UIWidget* UISceneNode::loadLayoutNodes( pugi::xml_node node, Node* parent, const
|
||||
std::string id( node.attribute( "id" ).as_string() );
|
||||
mIsLoading = true;
|
||||
Clock innerClock;
|
||||
std::vector<UIWidget*> widgets = loadNode( node, parent, marker );
|
||||
SmallVector<UIWidget*, 8> widgets = loadNode( node, parent, marker );
|
||||
|
||||
if ( mVerbose ) {
|
||||
std::sort(
|
||||
|
||||
@@ -581,8 +581,7 @@ void UIStyle::subscribeNonCacheableStyles() {
|
||||
return;
|
||||
for ( auto& style : mGlobalDefinition->getStyles() ) {
|
||||
if ( !style->getSelector().isCacheable() ) {
|
||||
std::vector<UIWidget*> elements =
|
||||
style->getSelector().getRelatedElements( mWidget, false );
|
||||
auto elements = style->getSelector().getRelatedElements( mWidget, false );
|
||||
|
||||
if ( !elements.empty() ) {
|
||||
for ( auto& element : elements ) {
|
||||
|
||||
+10
-11
@@ -1557,8 +1557,8 @@ const Uint32& UIWidget::getStylePreviousState() const {
|
||||
return NULL != mStyle ? mStyle->getPreviousState() : mState;
|
||||
}
|
||||
|
||||
std::vector<UIWidget*> UIWidget::findAllByClass( const std::string& className ) {
|
||||
std::vector<UIWidget*> widgets;
|
||||
WidgetQueryResult UIWidget::findAllByClass( const std::string& className ) {
|
||||
WidgetQueryResult widgets;
|
||||
|
||||
if ( !isClosing() && hasClass( className ) && !inClosingTree() ) {
|
||||
widgets.push_back( this );
|
||||
@@ -1568,8 +1568,7 @@ std::vector<UIWidget*> UIWidget::findAllByClass( const std::string& className )
|
||||
|
||||
while ( NULL != child ) {
|
||||
if ( child->isWidget() ) {
|
||||
std::vector<UIWidget*> foundWidgets =
|
||||
child->asType<UIWidget>()->findAllByClass( className );
|
||||
WidgetQueryResult foundWidgets = child->asType<UIWidget>()->findAllByClass( className );
|
||||
|
||||
if ( !foundWidgets.empty() )
|
||||
widgets.insert( widgets.end(), foundWidgets.begin(), foundWidgets.end() );
|
||||
@@ -1581,8 +1580,8 @@ std::vector<UIWidget*> UIWidget::findAllByClass( const std::string& className )
|
||||
return widgets;
|
||||
}
|
||||
|
||||
std::vector<UIWidget*> UIWidget::findAllByTag( const std::string& tag ) {
|
||||
std::vector<UIWidget*> widgets;
|
||||
WidgetQueryResult UIWidget::findAllByTag( const std::string& tag ) {
|
||||
WidgetQueryResult widgets;
|
||||
|
||||
if ( !isClosing() && getElementTag() == tag && !inClosingTree() ) {
|
||||
widgets.push_back( this );
|
||||
@@ -1592,7 +1591,7 @@ std::vector<UIWidget*> UIWidget::findAllByTag( const std::string& tag ) {
|
||||
|
||||
while ( NULL != child ) {
|
||||
if ( child->isWidget() ) {
|
||||
std::vector<UIWidget*> foundWidgets = child->asType<UIWidget>()->findAllByTag( tag );
|
||||
WidgetQueryResult foundWidgets = child->asType<UIWidget>()->findAllByTag( tag );
|
||||
|
||||
if ( !foundWidgets.empty() )
|
||||
widgets.insert( widgets.end(), foundWidgets.begin(), foundWidgets.end() );
|
||||
@@ -1667,8 +1666,8 @@ UIWidget* UIWidget::querySelector( const CSS::StyleSheetSelector& selector ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<UIWidget*> UIWidget::querySelectorAll( const CSS::StyleSheetSelector& selector ) {
|
||||
std::vector<UIWidget*> widgets;
|
||||
WidgetQueryResult UIWidget::querySelectorAll( const CSS::StyleSheetSelector& selector ) {
|
||||
WidgetQueryResult widgets;
|
||||
|
||||
if ( !isClosing() && !inClosingTree() && selector.select( this ) ) {
|
||||
widgets.push_back( this );
|
||||
@@ -1678,7 +1677,7 @@ std::vector<UIWidget*> UIWidget::querySelectorAll( const CSS::StyleSheetSelector
|
||||
|
||||
while ( NULL != child ) {
|
||||
if ( child->isWidget() ) {
|
||||
std::vector<UIWidget*> foundWidgets =
|
||||
WidgetQueryResult foundWidgets =
|
||||
child->asType<UIWidget>()->querySelectorAll( selector );
|
||||
|
||||
if ( !foundWidgets.empty() )
|
||||
@@ -1714,7 +1713,7 @@ UIWidget* UIWidget::querySelector( const std::string& selector ) {
|
||||
return querySelector( CSS::StyleSheetSelector( selector ) );
|
||||
}
|
||||
|
||||
std::vector<UIWidget*> UIWidget::querySelectorAll( const std::string& selector ) {
|
||||
WidgetQueryResult UIWidget::querySelectorAll( const std::string& selector ) {
|
||||
return querySelectorAll( CSS::StyleSheetSelector( selector ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -5837,7 +5837,7 @@ UTEST( UIHTML, RonStonerDeferredImagesUpdateDocumentHeight ) {
|
||||
ASSERT_TRUE( documentScene != nullptr );
|
||||
|
||||
UIWidget* body = nullptr;
|
||||
std::vector<UIWidget*> images;
|
||||
WidgetQueryResult images;
|
||||
for ( int i = 0; i < 300; ++i ) {
|
||||
pump();
|
||||
body = documentScene->getRoot()->findByType( UI_TYPE_HTML_BODY )->asType<UIWidget>();
|
||||
|
||||
@@ -157,7 +157,7 @@ class GitPlugin : public PluginBase {
|
||||
UIDropDownList* mPanelSwicher{ nullptr };
|
||||
UIDropDownList* mRepoDropDown{ nullptr };
|
||||
UIStackWidget* mStackWidget{ nullptr };
|
||||
std::vector<UIWidget*> mStackMap;
|
||||
SmallVector<UIWidget*, 4> mStackMap;
|
||||
UIWidget* mGitContentView{ nullptr };
|
||||
UIWidget* mGitNoContentView{ nullptr };
|
||||
UIWidget* mConflictStateBar{ nullptr };
|
||||
|
||||
Reference in New Issue
Block a user