• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neon-sunset / U8String / 5980222482

25 Aug 2023 08:35PM UTC coverage: 19.654% (-0.1%) from 19.773%
5980222482

push

github

neon-sunset
feat: finish updating to new abstraction, fix invalid reference in .Move

134 of 968 branches covered (0.0%)

Branch coverage included in aggregate %.

38 of 38 new or added lines in 8 files covered. (100.0%)

479 of 2151 relevant lines covered (22.27%)

38276.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.25
/src/U8String.Enumeration.cs
1
using System.Collections;
2

3
using Rune = System.Text.Rune;
4

5
namespace U8Primitives;
6

7
#pragma warning disable IDE0032, IDE0057 // Use auto property and index operator. Why: Perf, struct layout, accuracy and codegen.
8
public readonly partial struct U8String
9
{
10
    /// <summary>
11
    /// Returns a collection of <see cref="char"/>s over the provided string.
12
    /// </summary>
13
    /// <remarks>
14
    /// This is a lazily-evaluated allocation-free collection.
15
    /// </remarks>
16
    public U8Chars Chars
17
    {
18
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
19
        get => new(this);
30✔
20
    }
21

22
    /// <summary>
23
    /// Returns a collection of <see cref="Rune"/>s over the provided string.
24
    /// </summary>
25
    /// <remarks>
26
    /// This is a lazily-evaluated allocation-free collection.
27
    /// </remarks>
28
    public U8Runes Runes
29
    {
30
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
31
        get => new(this);
30✔
32
    }
33

34
    /// <summary>
35
    /// Returns a collection of lines over the provided string.
36
    /// </summary>
37
    /// <remarks>
38
    /// This is a lazily-evaluated allocation-free collection.
39
    /// </remarks>
40
    public U8Lines Lines
41
    {
42
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
43
        get => new(this);
×
44
    }
45

46
    // Bad codegen still :(
47
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
48
    public Enumerator GetEnumerator() => new(this);
12✔
49

50
    IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
×
51
    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
6✔
52

53
    public struct Enumerator : IEnumerator<byte>
54
    {
55
        readonly byte[]? _value;
56
        readonly int _offset;
57
        readonly int _length;
58
        int _index;
59

60
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
61
        public Enumerator(U8String value)
62
        {
63
            _value = value._value;
12✔
64
            _offset = value.Offset;
12✔
65
            _length = value.Length;
12✔
66
            _index = -1;
12✔
67
        }
12✔
68

69
        // Still cheaper than MemoryMarshal clever variants
70
        public readonly byte Current => _value![_offset + _index];
3,138✔
71

72
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
73
        public bool MoveNext() => (uint)(++_index) < (uint)_length;
3,156✔
74
        // {
75
        //     var index = _index;
76
        //     if (++index < _length)
77
        //     {
78
        //         // Current = Unsafe.Add(
79
        //         //     ref MemoryMarshal.GetArrayDataReference(_value!),
80
        //         //     (nint)(uint)(_offset + index));
81
        //         Current = _value![_offset + index];
82
        //         _index = index;
83
        //         return true;
84
        //     }
85

86
        //     return false;
87
        // }
88

89
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
90
        public void Reset() => _index = -1;
×
91

92
        readonly object IEnumerator.Current => Current;
1,569✔
93
        readonly void IDisposable.Dispose() { }
6✔
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc