Skip to content

refactor(Noder): optimize line splitting using ReadOnlySpan#34

Merged
Lemon73-Computing merged 5 commits into
mainfrom
lemon73/improve-noder
May 9, 2026
Merged

refactor(Noder): optimize line splitting using ReadOnlySpan#34
Lemon73-Computing merged 5 commits into
mainfrom
lemon73/improve-noder

Conversation

@Lemon73-Computing
Copy link
Copy Markdown
Member

@Lemon73-Computing Lemon73-Computing commented May 9, 2026

Summary

Improved the processes of Noder.

Details

In Noder processing, replacing operations on string and string[] with ReadOnlySpan and List<string> has resulted in faster and more lightweight processing.

See also: https://github.com/AliceNovel/CommonNovel/pull/34/changes#diff-51e1cf45389002daed215ce0327155a875852fddba52326385b7afa56daabe09R10-R47

Breaking Changes

Caution

This PR contains breaking changes.

Benchmark

BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8328/25H2/2025Update/HudsonValley2)
13th Gen Intel Core i7-13700H 2.40GHz, 1 CPU, 20 logical and 14 physical cores
.NET SDK 10.0.103
  [Host]     : .NET 10.0.3 (10.0.3, 10.0.326.7603), X64 RyuJIT x86-64-v3
  DefaultJob : .NET 10.0.3 (10.0.3, 10.0.326.7603), X64 RyuJIT x86-64-v3

Before

Method Mean Error StdDev Gen0 Allocated
RunNoder 104.307 ns 1.9910 ns 3.8361 ns 0.0497 624 B

After

Method Mean Error StdDev Gen0 Allocated
RunNoder 51.757 ns 1.0359 ns 1.1929 ns 0.0197 248 B

@Lemon73-Computing Lemon73-Computing self-assigned this May 9, 2026
@Lemon73-Computing Lemon73-Computing added enhancement New feature or request csharp Implementations of C# labels May 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Code Coverage

Result: success

Show coverage summary

Summary

Generated on: 05/09/2026 - 07:46:31
Coverage date: 05/09/2026 - 07:46:28
Parser: Cobertura
Assemblies: 1
Classes: 1
Files: 3
Line coverage: 100% (73 of 73)
Covered lines: 73
Uncovered lines: 0
Coverable lines: 73
Total lines: 145
Branch coverage: 100% (28 of 28)
Covered branches: 28
Total branches: 28
Method coverage: Feature is only available for sponsors

Risk Hotspots

Assembly Class Method Crap Score Cyclomatic complexity
CommonNovel CommonNovel.Compiler Noder(...) 16 16

Coverage

Name Covered Uncovered Coverable Total Line coverage Covered Total Branch coverage
CommonNovel 73 0 73 145 100% 28 28 100%
CommonNovel.Compiler 73 0 73 145 100% 28 28 100%

gemini-code-assist[bot]

This comment was marked as resolved.

@Lemon73-Computing
Copy link
Copy Markdown
Member Author

/gemini summary

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

This pull request refactors the Noder component to optimize performance by leveraging ReadOnlySpan for string manipulation. The changes include a shift in how line breaks are interpreted and processed, resulting in more predictable and efficient node generation. While this introduces breaking changes regarding how empty lines and line breaks are handled, it significantly reduces memory overhead and improves processing speed as demonstrated by the provided benchmarks.

Highlights

  • Performance Optimization: Replaced string-based processing with ReadOnlySpan and List to reduce memory allocations and improve execution speed.
  • Line Splitting Logic: Updated the Noder logic to handle line breaks based on character sequences rather than environment-dependent settings, ensuring consistent behavior across platforms.
  • Breaking Changes: Adjusted node generation to correctly handle consecutive line breaks, which now produce empty string elements instead of being ignored.
Activity
  • The pull request was created by Lemon73-Computing.
  • A code coverage report was generated by the CI bot, showing 100% coverage.
  • Automated review comments were posted highlighting potential functional regressions and concerns regarding empty node handling.
  • The author requested a summary of the pull request.

@Lemon73-Computing Lemon73-Computing merged commit d1e6a99 into main May 9, 2026
1 check passed
@Lemon73-Computing Lemon73-Computing deleted the lemon73/improve-noder branch May 9, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

csharp Implementations of C# enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant