Skip to content

Commit 369860c

Browse files
committed
clean up unused changes
1 parent fbe1d1b commit 369860c

File tree

6 files changed

+14
-236
lines changed

6 files changed

+14
-236
lines changed
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using System;
2-
using System.Text;
31
using BenchmarkDotNet.Attributes;
42
using BenchmarkDotNet.Attributes.Exporters;
53
using BenchmarkDotNet.Attributes.Jobs;
6-
using JsonApiDotNetCore.Extensions;
74

85
namespace Benchmarks.LinkBuilder
96
{
@@ -16,9 +13,6 @@ public class LinkBuilder_GetNamespaceFromPath_Benchmarks
1613
[Benchmark]
1714
public void UsingSplit() => GetNamespaceFromPath_BySplitting(PATH, ENTITY_NAME);
1815

19-
[Benchmark]
20-
public void UsingSpanWithStringBuilder() => GetNamespaceFromPath_Using_Span_With_StringBuilder(PATH, ENTITY_NAME);
21-
2216
[Benchmark]
2317
public void Current() => GetNameSpaceFromPath_Current(PATH, ENTITY_NAME);
2418

@@ -40,21 +34,5 @@ public static string GetNamespaceFromPath_BySplitting(string path, string entity
4034

4135
public static string GetNameSpaceFromPath_Current(string path, string entityName)
4236
=> JsonApiDotNetCore.Builders.LinkBuilder.GetNamespaceFromPath(path, entityName);
43-
44-
public static string GetNamespaceFromPath_Using_Span_With_StringBuilder(string path, string entityName)
45-
{
46-
var sb = new StringBuilder();
47-
var entityNameSpan = entityName.AsSpan();
48-
var subSpans = path.SpanSplit('/');
49-
for (var i = 1; i < subSpans.Count; i++)
50-
{
51-
var span = subSpans[i];
52-
if (entityNameSpan.SequenceEqual(span))
53-
break;
54-
55-
sb.Append($"/{span.ToString()}");
56-
}
57-
return sb.ToString();
58-
}
5937
}
6038
}

src/JsonApiDotNetCore/Extensions/StringExtensions.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.Text;
4-
using JsonApiDotNetCore.Internal;
52

63
namespace JsonApiDotNetCore.Extensions
74
{
@@ -53,21 +50,5 @@ public static string Dasherize(this string str)
5350
}
5451
return str;
5552
}
56-
57-
public static IEnumerable<int> IndexesOf(this string str, char delimeter)
58-
{
59-
var indexes = new List<int>();
60-
for (var i = str.IndexOf(delimeter); i > -1 ; i = str.IndexOf(delimeter, i+1))
61-
{
62-
indexes.Add(i);
63-
}
64-
return indexes;
65-
}
66-
67-
public static SpanSplitter SpanSplit(this string str, char delimeter)
68-
{
69-
return SpanSplitter.Split(str, delimeter);
70-
}
71-
7253
}
7354
}

src/JsonApiDotNetCore/Internal/Query/RelatedAttrFilterQuery.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ public class RelatedAttrFilterQuery : BaseFilterQuery
1111
private readonly IJsonApiContext _jsonApiContext;
1212

1313
public RelatedAttrFilterQuery(
14-
IJsonApiContext jsonApiCopntext,
14+
IJsonApiContext jsonApiContext,
1515
FilterQuery filterQuery)
1616
{
17-
_jsonApiContext = jsonApiCopntext;
18-
var filterQueryAttribute = filterQuery.Attribute;
19-
var filterQuerySubSpans = filterQueryAttribute.SpanSplit('.');
20-
var subSpan1 = filterQuerySubSpans[0].ToString();
21-
var subSpan2 = filterQuerySubSpans[1].ToString();
22-
var relationship = GetRelationship(subSpan1);
23-
if (relationship == null)
24-
throw new JsonApiException(400, $"{subSpan2} is not a valid relationship on {subSpan1}.");
17+
_jsonApiContext = jsonApiContext;
2518

26-
var attribute = GetAttribute(relationship, subSpan2);
19+
var relationshipArray = filterQuery.Attribute.Split('.');
20+
var relationship = GetRelationship(relationshipArray[0]);
21+
if (relationship == null)
22+
throw new JsonApiException(400, $"{relationshipArray[1]} is not a valid relationship on {relationshipArray[0]}.");
2723

24+
var attribute = GetAttribute(relationship, relationshipArray[1]);
2825
if (attribute == null)
2926
throw new JsonApiException(400, $"'{filterQuery.Attribute}' is not a valid attribute.");
3027

src/JsonApiDotNetCore/Internal/SpanSplitter.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/JsonApiDotNetCore/Services/QueryParser.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using JsonApiDotNetCore.Configuration;
55
using JsonApiDotNetCore.Controllers;
6-
using JsonApiDotNetCore.Extensions;
76
using JsonApiDotNetCore.Internal;
87
using JsonApiDotNetCore.Internal.Query;
98
using JsonApiDotNetCore.Models;
@@ -94,16 +93,16 @@ protected virtual List<FilterQuery> ParseFilterQuery(string key, string value)
9493
// expected input = filter[id]=1
9594
// expected input = filter[id]=eq:1
9695
var queries = new List<FilterQuery>();
97-
var openBracketIndex = key.IndexOf(OPEN_BRACKET);
98-
var closedBracketIndex = key.IndexOf(CLOSE_BRACKET);
99-
var propertyNameSlice = key.AsSpan().Slice(openBracketIndex + 1, closedBracketIndex - openBracketIndex - 1);
100-
var propertyName = propertyNameSlice.ToString();
10196

102-
var spanSplitter = value.SpanSplit(COMMA);
103-
for (var i = 0; i < spanSplitter.Count; i++)
97+
var propertyName = key.Split(OPEN_BRACKET, CLOSE_BRACKET)[1];
98+
99+
var values = value.Split(COMMA);
100+
foreach (var val in values)
104101
{
105-
queries.Add(BuildFilterQuery(spanSplitter[i], propertyName));
102+
(var operation, var filterValue) = ParseFilterOperation(val);
103+
queries.Add(new FilterQuery(propertyName, filterValue, operation));
106104
}
105+
107106
return queries;
108107
}
109108

test/UnitTests/Internal/SpanSplitterTests.cs

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)