Skip to content

Commit 71a77de

Browse files
authored
No allocations in ResponseItem IsValid prop (#7731)
1 parent 85146f0 commit 71a77de

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/Elastic.Clients.Elasticsearch/Api/ResponseItem.cs

+14-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
6+
57
namespace Elastic.Clients.Elasticsearch.Core.Bulk;
68

79
public abstract partial class ResponseItem
@@ -15,12 +17,19 @@ public bool IsValid
1517
if (Error is not null)
1618
return false;
1719

18-
return Operation.ToLowerInvariant() switch
20+
var operation = Operation;
21+
22+
if (operation.Equals("delete", StringComparison.OrdinalIgnoreCase))
23+
return Status is 200 or 404;
24+
25+
if (operation.Equals("create", StringComparison.OrdinalIgnoreCase) ||
26+
operation.Equals("update", StringComparison.OrdinalIgnoreCase) ||
27+
operation.Equals("index", StringComparison.OrdinalIgnoreCase))
1928
{
20-
"delete" => Status == 200 || Status == 404,
21-
"update" or "index" or "create" => Status == 200 || Status == 201,
22-
_ => false,
23-
};
29+
return Status is 200 or 201;
30+
}
31+
32+
return false;
2433
}
2534
}
2635
}

0 commit comments

Comments
 (0)