Fix IDE0057: Substring can be simplified

This commit is contained in:
Haselnussbomber 2025-10-24 04:16:05 +02:00
parent 94b7f89281
commit 3050ea7ded
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
6 changed files with 6 additions and 6 deletions

View file

@ -71,7 +71,7 @@ internal sealed unsafe class CommandManager : IInternalDisposableService, IComma
if (separatorPosition + 1 >= content.Length)
{
// Remove the trailing space
command = content.Substring(0, separatorPosition);
command = content[..separatorPosition];
}
else
{

View file

@ -110,7 +110,7 @@ internal static unsafe class ImGuiInputTextStatePtrExtensions
var text = new Span<char>(self.TextW.Data, self.TextW.Size);
if (pos != textLen)
text.Slice(pos, textLen - pos).CopyTo(text[(pos + newText.Length)..]);
text[pos..textLen].CopyTo(text[(pos + newText.Length)..]);
newText.CopyTo(text[pos..]);
self.Edited = true;

View file

@ -68,7 +68,7 @@ public abstract class StyleModel
/// <exception cref="ArgumentException">Thrown in case the version of the model is not known.</exception>
public static StyleModel? Deserialize(string model)
{
var json = Util.DecompressString(Convert.FromBase64String(model.Substring(3)));
var json = Util.DecompressString(Convert.FromBase64String(model[3..]));
if (model.StartsWith(StyleModelV1.SerializedPrefix))
return JsonConvert.DeserializeObject<StyleModelV1>(json);

View file

@ -243,7 +243,7 @@ internal class ManagedLoadContext : AssemblyLoadContext
}
// check to see if there is a library entry for the library without the file extension
var trimmedName = unmanagedDllName.Substring(0, unmanagedDllName.Length - suffix.Length);
var trimmedName = unmanagedDllName[..^suffix.Length];
if (this.nativeLibraries.TryGetValue(prefix + trimmedName, out library))
{

View file

@ -32,7 +32,7 @@ public abstract class ProfileModel
/// <exception cref="ArgumentException">Thrown when the parsed string is not a valid profile.</exception>
public static ProfileModel? Deserialize(string model)
{
var json = Util.DecompressString(Convert.FromBase64String(model.Substring(3)));
var json = Util.DecompressString(Convert.FromBase64String(model[3..]));
if (model.StartsWith(ProfileModelV1.SerializedPrefix))
return JsonConvert.DeserializeObject<ProfileModelV1>(json);

View file

@ -182,7 +182,7 @@ public static class SafeMemory
return null;
var data = encoding.GetString(buffer);
var eosPos = data.IndexOf('\0');
return eosPos == -1 ? data : data.Substring(0, eosPos);
return eosPos == -1 ? data : data[..eosPos];
}
/// <summary>