Skip to content

Commit 533403c

Browse files
committed
Rely on first-class span conversions of C# 14
1 parent c4324c9 commit 533403c

4 files changed

Lines changed: 6 additions & 10 deletions

File tree

src/core/IronPython/Hosting/PythonOptionsParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ protected override void ParseArgument(string/*!*/ arg) {
150150
}
151151

152152
if (arg == "/?" || arg == "--help") {
153-
HandleOptions("h".AsSpan());
153+
HandleOptions("h");
154154
return;
155155
}
156156

157157
if (arg == "--version") {
158-
HandleOptions("V".AsSpan());
158+
HandleOptions("V");
159159
return;
160160
}
161161

src/core/IronPython/Modules/_io/StringIO.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private string readline(int limit) {
114114
span = span.Slice(0, idx + 1);
115115
}
116116
} else if (_newline == string.Empty) {
117-
var idx = span.IndexOfAny("\r\n".AsSpan());
117+
var idx = span.IndexOfAny("\r\n");
118118
if (idx != -1) {
119119
if (span[idx++] == '\r') {
120120
// ensure we don't split \r\n
@@ -377,7 +377,7 @@ private int DoWrite(string str) {
377377

378378
if (_newline is null) {
379379
while (true) {
380-
var idx = span.IndexOfAny("\r\n".AsSpan());
380+
var idx = span.IndexOfAny("\r\n");
381381
if (idx == -1)
382382
break;
383383

src/core/IronPython/Runtime/LiteralParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void handleError(in ReadOnlySpan<T> data, int start, int end, string reason) {
219219
#nullable enable
220220

221221
private static bool TryParseExpression(Parser parser, ReadOnlySpan<char> data, [NotNullWhen(true)] out Expression? expression, [NotNullWhen(false)] out string? error) {
222-
if (data.TrimStart(" \t\f\r\n".AsSpan()).Length == 0) {
222+
if (data.TrimStart(" \t\f\r\n").Length == 0) {
223223
expression = null;
224224
error = "f-string: empty expression not allowed";
225225
return false;
@@ -649,7 +649,7 @@ private static bool TryParseInt<T>(in ReadOnlySpan<T> text, int start, int lengt
649649
}
650650

651651
public static object ParseInteger(string text, int b) {
652-
if (TryParseInteger(text.AsSpan(), b, false, out object val)) {
652+
if (TryParseInteger(text, b, false, out object val)) {
653653
return val;
654654
}
655655
throw new ValueErrorException($"invalid literal with base {b}: {text}");

src/core/IronPython/Runtime/Operations/PythonOps.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3689,10 +3689,6 @@ internal static string MakeString(this IList<byte> bytes, int startIdx, int maxB
36893689
return StringOps.Latin1Encoding.GetString(byteArr, startIdx, maxBytes);
36903690
}
36913691

3692-
internal static string MakeString(this Span<byte> bytes) {
3693-
return MakeString((ReadOnlySpan<byte>)bytes);
3694-
}
3695-
36963692
internal static string MakeString(this ReadOnlySpan<byte> bytes) {
36973693
if (bytes.IsEmpty) {
36983694
return string.Empty;

0 commit comments

Comments
 (0)