diff --git a/include/eepp/graphics/fonttruetype.hpp b/include/eepp/graphics/fonttruetype.hpp index 81d64cbdf..5e12afc6a 100644 --- a/include/eepp/graphics/fonttruetype.hpp +++ b/include/eepp/graphics/fonttruetype.hpp @@ -105,11 +105,12 @@ class EE_API FontTrueType : public Font { unsigned int height; ///< Height of the row }; - typedef std::map GlyphTable; ///< Table mapping a codepoint to its glyph - typedef std::map GlyphDrawableTable; + typedef std::unordered_map + GlyphTable; ///< Table mapping a codepoint to its glyph + typedef std::unordered_map GlyphDrawableTable; struct Page { - Page( const Uint32 fontInternalId ); + explicit Page( const Uint32 fontInternalId ); ~Page(); @@ -166,11 +167,8 @@ class EE_API FontTrueType : public Font { bool mEnableEmojiFallback{ true }; bool mEnableFallbackFont{ true }; bool mEnableDynamicMonospace{ false }; - mutable std::map mClosestCharacterSize; - mutable std::map mCodePointIndexCache; - - Uint64 getIndexKey( Uint32 fontInternalId, Uint32 index, bool bold, - Float outlineThickness ) const; + mutable std::unordered_map mClosestCharacterSize; + mutable std::unordered_map mCodePointIndexCache; void updateFontInternalId(); }; diff --git a/include/eepp/ui/doc/syntaxhighlighter.hpp b/include/eepp/ui/doc/syntaxhighlighter.hpp index 91e26c8a7..e465c98a7 100644 --- a/include/eepp/ui/doc/syntaxhighlighter.hpp +++ b/include/eepp/ui/doc/syntaxhighlighter.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace EE { namespace UI { namespace Doc { @@ -16,7 +16,7 @@ struct TokenizedLine { class EE_API SyntaxHighlighter { public: - SyntaxHighlighter( TextDocument* doc ); + explicit SyntaxHighlighter( TextDocument* doc ); void changeDoc( TextDocument* doc ); @@ -40,7 +40,7 @@ class EE_API SyntaxHighlighter { protected: TextDocument* mDoc; - std::map mLines; + std::unordered_map mLines; Int64 mFirstInvalidLine; Int64 mMaxWantedLine; TokenizedLine tokenizeLine( const size_t& line, const Uint64& state ); diff --git a/include/eepp/ui/uicodeeditor.hpp b/include/eepp/ui/uicodeeditor.hpp index f9e9f45e7..a9d5117aa 100644 --- a/include/eepp/ui/uicodeeditor.hpp +++ b/include/eepp/ui/uicodeeditor.hpp @@ -593,9 +593,9 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { Vector2f getRelativeScreenPosition( const TextPosition& pos ); bool getShowLinesRelativePosition() const; - void showLinesRelativePosition(bool showLinesRelativePosition); + void showLinesRelativePosition( bool showLinesRelativePosition ); - protected: + protected: struct LastXOffset { TextPosition position{ 0, 0 }; Float offset{ 0.f }; @@ -662,7 +662,7 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { SyntaxColorScheme mColorScheme; UIScrollBar* mVScrollBar; UIScrollBar* mHScrollBar; - std::map mLastXOffset; + std::unordered_map mLastXOffset; KeyBindings mKeyBindings; std::unordered_set mUnlockedCmd; Clock mLastDoubleClick; @@ -687,7 +687,7 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { Text text; String::HashType hash; }; - mutable std::map mTextCache; + mutable std::unordered_map mTextCache; Tools::UIDocFindReplace* mFindReplace{ nullptr }; struct PluginRequestedSpace { UICodeEditorPlugin* plugin; @@ -699,6 +699,7 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { std::vector mPluginTopSpaces; Float mPluginsTopSpace{ 0 }; Uint64 mLastExecuteEventId{ 0 }; + Text mLineTextCache; UICodeEditor( const std::string& elementTag, const bool& autoRegisterBaseCommands = true, const bool& autoRegisterBaseKeybindings = true ); diff --git a/src/eepp/graphics/fonttruetype.cpp b/src/eepp/graphics/fonttruetype.cpp index 72ac1b636..39fa8b536 100644 --- a/src/eepp/graphics/fonttruetype.cpp +++ b/src/eepp/graphics/fonttruetype.cpp @@ -43,14 +43,6 @@ template inline T reinterpret( const U& input ) { return output; } -// Combine outline thickness, boldness and font glyph index into a single 64-bit key -EE::Uint64 combine( float outlineThickness, bool bold, EE::Uint32 index, - EE::Uint32 fontInternalId ) { - return ( static_cast( reinterpret( fontInternalId ) ) << 48 ) | - ( static_cast( reinterpret( outlineThickness * 100 ) ) << 33 ) | - ( static_cast( bold ) << 32 ) | index; -} - } // namespace namespace EE { namespace Graphics { @@ -58,6 +50,14 @@ namespace EE { namespace Graphics { static std::map fontsInternalIds; static std::atomic fontInternalIdCounter{ 0 }; +// Combine outline thickness, boldness and font glyph index into a single 64-bit key +static inline Uint64 getIndexKey( Uint32 fontInternalId, Uint32 index, bool bold, + Float outlineThickness ) { + return ( static_cast( reinterpret( fontInternalId ) ) << 48 ) | + ( static_cast( reinterpret( outlineThickness * 100 ) ) << 33 ) | + ( static_cast( bold ) << 32 ) | index; +} + FontTrueType* FontTrueType::New( const std::string& FontName ) { return eeNew( FontTrueType, ( FontName ) ); } @@ -348,11 +348,6 @@ const FontTrueType::Info& FontTrueType::getInfo() const { return mInfo; } -Uint64 FontTrueType::getIndexKey( Uint32 fontInternalId, Uint32 index, bool bold, - Float outlineThickness ) const { - return combine( outlineThickness, bold, index, fontInternalId ); -} - void FontTrueType::updateFontInternalId() { auto fontInternalId = fontsInternalIds.find( mInfo.family ); if ( fontsInternalIds.end() == fontInternalId ) { diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index f33590f46..23a04b78e 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -267,11 +267,11 @@ Node* Node::setParent( Node* parent ) { bool Node::isParentOf( const Node* node ) const { eeASSERT( NULL != node ); - Node* tParent = node->getParent(); + Node* tParent = node->mParentNode; while ( NULL != tParent ) { if ( this == tParent ) return true; - tParent = tParent->getParent(); + tParent = tParent->mParentNode; } return false; } diff --git a/src/eepp/system/process.cpp b/src/eepp/system/process.cpp index b301dbf30..a0b298dd9 100644 --- a/src/eepp/system/process.cpp +++ b/src/eepp/system/process.cpp @@ -65,11 +65,6 @@ bool Process::create( const std::string& command, const Uint32& options, } envStrings.push_back( NULL ); - std::string cwd; - if ( !workingDirectory.empty() ) { - cwd = FileSystem::getCurrentWorkingDirectory(); - } - auto ret = 0 == subprocess_create_ex( strings.data(), options, envStrings.data(), !workingDirectory.empty() ? workingDirectory.c_str() : nullptr, diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index e843037c2..759f27a92 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -1573,8 +1573,6 @@ void UICodeEditor::onDocumentLineCountChange( const size_t&, const size_t& ) { void UICodeEditor::onDocumentLineChanged( const Int64& lineNumber ) { mDoc->getHighlighter()->invalidate( lineNumber ); - if ( mFont && !mFont->isMonospace() ) - updateLineCache( lineNumber ); if ( !mHighlightWord.isEmpty() ) updateHighlightWordCache(); @@ -1755,12 +1753,8 @@ size_t UICodeEditor::characterWidth( const String& str ) const { Float UICodeEditor::getTextWidth( const String& line ) const { if ( mFont && !mFont->isMonospace() ) { - Float fontSize = PixelDensity::pxToDp( getCharacterSize() ); - Text txt( "", mFont, fontSize ); - txt.setTabWidth( mTabWidth ); - txt.setStyleConfig( mFontStyleConfig ); - txt.setString( line ); - return txt.getTextWidth(); + return Text::getTextWidth( mFont, getCharacterSize(), line, mFontStyleConfig.Style, + mTabWidth ); } Float glyphWidth = getGlyphWidth(); @@ -2713,6 +2707,9 @@ void UICodeEditor::drawLineText( const Int64& line, Vector2f position, const Flo ttf->setEnableFallbackFont( false ); ttf->setEnableEmojiFallback( false ); } + + Text& txt = mLineTextCache; + for ( const auto& token : tokens ) { String text( pos < strLine.size() ? strLine.substr( pos, token.len ) : String() ); pos += token.len; @@ -2723,12 +2720,12 @@ void UICodeEditor::drawLineText( const Int64& line, Vector2f position, const Flo Int64 curCharsWidth = text.size(); Int64 curPositionChar = eefloor( mScroll.x / getGlyphWidth() ); Float curMaxPositionChar = curPositionChar + maxWidth; - Text txt( "", mFont, fontSize ); + txt.setFont( mFont ); + txt.setFontSize( fontSize ); txt.setTabWidth( mTabWidth ); const SyntaxColorScheme::Style& style = mColorScheme.getSyntaxStyle( token.type ); txt.setStyleConfig( mFontStyleConfig ); - if ( style.style ) - txt.setStyle( style.style ); + txt.setStyle( style.style ); txt.setColor( Color( style.color ).blendAlpha( mAlpha ) ); if ( isMonospace ) diff --git a/src/tools/ecode/plugins/autocomplete/autocompleteplugin.hpp b/src/tools/ecode/plugins/autocomplete/autocompleteplugin.hpp index 93a9dad30..8db3d4b00 100644 --- a/src/tools/ecode/plugins/autocomplete/autocompleteplugin.hpp +++ b/src/tools/ecode/plugins/autocomplete/autocompleteplugin.hpp @@ -127,7 +127,6 @@ class AutoCompletePlugin : public UICodeEditorPlugin { }; std::unordered_map mDocCache; std::unordered_map mLangCache; - SymbolsList mLangDirty; std::vector mSuggestions; Mutex mSuggestionsEditorMutex; @@ -137,15 +136,14 @@ class AutoCompletePlugin : public UICodeEditorPlugin { Int32 mSuggestionIndex{ 0 }; Int32 mSuggestionsMaxVisible{ 8 }; Int32 mSuggestionsStartIndex{ 0 }; - std::map mCapabilities; + std::unordered_map mCapabilities; Mutex mCapabilitiesMutex; LSPSignatureHelp mSignatureHelp; TextPosition mSignatureHelpPosition; Int32 mSignatureHelpSelected{ -1 }; Mutex mHandlesMutex; - std::map> mHandles; - - std::map> mDocsUpdating; + std::unordered_map> mHandles; + std::unordered_map> mDocsUpdating; Mutex mDocsUpdatingMutex; Float mRowHeight{ 0 };