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
Open
Conversation
…gh refs instead of copying & collection tweaks
Author
|
Also see gitextensions/gitextensions#13107 |
There was a problem hiding this comment.
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 (
[]) andCollectionsMarshal.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) | ||
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Blocks gitextensions/gitextensions#13110