Skip to content

Made some classes sealed, made it possible to pass some structs throgh refs instead of copying & collection tweaks#62

Open
Henr1k80 wants to merge 1 commit into
gitextensions:masterfrom
Henr1k80:master
Open

Made some classes sealed, made it possible to pass some structs throgh refs instead of copying & collection tweaks#62
Henr1k80 wants to merge 1 commit into
gitextensions:masterfrom
Henr1k80:master

Conversation

@Henr1k80

Copy link
Copy Markdown

…gh refs instead of copying & collection tweaks
@Henr1k80

Copy link
Copy Markdown
Author

Also see gitextensions/gitextensions#13107

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR applies a set of performance/immutability-oriented tweaks across the text editor library, primarily by sealing implementation types, reducing struct copying via in parameters, and using span-based list iteration in a few hot paths.

Changes:

  • Mark multiple internal/private helper classes as sealed.
  • Change several method/delegate signatures to accept common structs via in (e.g., Rectangle, RectangleF, Color).
  • Optimize some list allocations/iterations using collection expressions ([]) and CollectionsMarshal.AsSpan.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Project/Src/Util/TipText.cs Seals CountTipText.
Project/Src/Util/TipSplitter.cs Seals TipSplitter.
Project/Src/Util/TipSpacer.cs Seals TipSpacer.
Project/Src/Util/MouseWheelHandler.cs Seals MouseWheelHandler.
Project/Src/Util/LookupTable.cs Seals internal Node type.
Project/Src/Undo/UndoStack.cs Seals nested undo operation type.
Project/Src/Gui/TextView.cs Switches several drawing-related parameters to in to reduce copying.
Project/Src/Gui/TextEditorControl.cs Passes RectangleF by in in a printing helper.
Project/Src/Gui/InsightWindow/InsightWindow.cs Seals a nested stack element class.
Project/Src/Gui/Ime.cs Seals IME helper and nested interop carrier classes.
Project/Src/Gui/IconBarMargin.cs Updates Paint signature to in Rectangle.
Project/Src/Gui/GutterMargin.cs Updates Paint signature to in Rectangle.
Project/Src/Gui/FoldMargin.cs Updates Paint signature; passes RectangleF by in in drawing helper.
Project/Src/Gui/DrawableLine.cs Seals nested SimpleTextWord.
Project/Src/Gui/Caret.cs Seals nested caret implementation classes.
Project/Src/Gui/AbstractMargin.cs Changes public paint delegate + virtual Paint to use in Rectangle.
Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs Uses [] empty array initialization for the buffer.
Project/Src/Document/Selection/SelectionManager.cs Uses [] for list initialization; iterates lists via CollectionsMarshal.AsSpan; seals helper classes.
Project/Src/Document/MarkerStrategy/TextMarker.cs Changes public constructors to take Color via in.
Project/Src/Document/LineManager/LineSegmentTree.cs Makes RBNode.lineSegment readonly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 15 to 18
public delegate void MarginMouseEventHandler(AbstractMargin sender, Point mousepos, MouseButtons mouseButtons);

public delegate void MarginPaintEventHandler(AbstractMargin sender, Graphics g, Rectangle rect);
public delegate void MarginPaintEventHandler(AbstractMargin sender, Graphics g, in Rectangle rect);

Comment on lines +81 to 84
public virtual void Paint(Graphics g, in Rectangle rect)
{
Painted?.Invoke(this, g, rect);
}
Comment on lines 30 to 35
public TextMarker(int offset, int length, TextMarkerType textMarkerType) : this(offset, length, textMarkerType, Color.Red)
{
}

public TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color)
public TextMarker(int offset, int length, TextMarkerType textMarkerType, in Color color)
{
Comment on lines 41 to 44
}

public TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color foreColor)
public TextMarker(int offset, int length, TextMarkerType textMarkerType, in Color color, in Color foreColor)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants