Skip to content

Commit 5ce4009

Browse files
committed
Address PR feedback from dotnet#2579
We don't need a TryConvert method, we already have a TryParse, which can be used instead.
1 parent f9d5ec2 commit 5ce4009

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

src/Microsoft.ML.Data/Data/Conversion.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,17 +1585,6 @@ public void Convert(in TX span, ref I4 value)
15851585
{
15861586
value = ParseI4(in span);
15871587
}
1588-
public bool TryConvert(in TX span, ref I4 value)
1589-
{
1590-
TryParseSigned(I4.MaxValue, in span, out long? res);
1591-
if (res.HasValue)
1592-
{
1593-
value = (I4)res.GetValueOrDefault();
1594-
return true;
1595-
}
1596-
1597-
return false;
1598-
}
15991588
public void Convert(in TX span, ref U4 value)
16001589
{
16011590
value = ParseU4(in span);

src/Microsoft.ML.Data/DataLoadSave/Text/TextLoaderParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,8 @@ public int GatherFields(ReadOnlyMemory<char> lineSpan, ReadOnlySpan<char> span,
10161016
}
10171017
var spanT = Fields.Spans[Fields.Count - 1];
10181018

1019-
int csrc = 0;
1020-
if (!Conversions.Instance.TryConvert(in spanT, ref csrc) || csrc <= 0)
1019+
int csrc;
1020+
if (!Conversions.Instance.TryParse(in spanT, out csrc) || csrc <= 0)
10211021
{
10221022
_stats.LogBadFmt(ref scan, "Bad dimensionality or ambiguous sparse item. Use sparse=- for non-sparse file, and/or quote the value.");
10231023
break;

0 commit comments

Comments
 (0)