Skip to content

Commit

Permalink
Use more optimized methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornbouetsmith committed Jun 8, 2024
1 parent 2963d29 commit de88b01
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Source/ROOT.Zfs.Core/Helpers/ZPoolStatusParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private static VDev ParseVDev(string[] lines, ref int currentIndex)
{
break;
}
} while (trimmed.StartsWith("/") && currentIndex <= lines.Length);
} while (trimmed.StartsWith('/') && currentIndex <= lines.Length);

return vdev;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ROOT.Zfs.Core/Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public PropertyValue Set(SetPropertyArgs args)
var getArgs = new GetPropertyArgs { PropertyTarget = args.PropertyTarget, Property = args.Property, Target = args.Target };

// Should be safe - if not, then the set above would have failed - if we could not find a property to set
return Get(getArgs).First();
return Get(getArgs)[0];
}

/// <inheritdoc />
Expand Down
10 changes: 5 additions & 5 deletions Source/ROOT.Zfs.Public/Data/Size.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ public static Size FromSizeString(string sizeString)
return new Size();
}

if (!sizeString.EndsWith("B")
&& !sizeString.EndsWith("K")
&& !sizeString.EndsWith("M")
&& !sizeString.EndsWith("G")
&& !sizeString.EndsWith("T"))
if (!sizeString.EndsWith('B')
&& !sizeString.EndsWith('K')
&& !sizeString.EndsWith('M')
&& !sizeString.EndsWith('G')
&& !sizeString.EndsWith('T'))
{
throw new ArgumentException("size must be a string that ends in either B, K, M, G, T");
}
Expand Down
6 changes: 3 additions & 3 deletions Source/ROOT.Zfs.Tests/Helpers/SmartInfoParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ public void GarbledOrNotSupportedOutShouldNotThrowExceptios()
var stdOut = @"Smart data not supported";

var info = SmartInfoParser.ParseStdOut("/dev/sda", stdOut);
Assert.AreEqual(true, info.ParsingFailed);
Assert.IsTrue(info.ParsingFailed);
}

[TestMethod]
Expand Down Expand Up @@ -679,7 +679,7 @@ public void PartialOutputShouldNotThrowExceptions()
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 17";
var info = SmartInfoParser.ParseStdOut("/dev/sda", stdOut);
Assert.AreEqual(true, info.ParsingFailed);
Assert.IsTrue(info.ParsingFailed);
}

[TestMethod]
Expand Down Expand Up @@ -709,7 +709,7 @@ public void PartialAndGarbledOutputShouldNotThrowExceptions()
=== START OF READ SMART DATA SECTION ===SMART overall-health self-assessment test result:PASSEDSMART Attributes Data Structure revision number: 17
";
var info = SmartInfoParser.ParseStdOut("/dev/sda", stdOut);
Assert.AreEqual(true, info.ParsingFailed);
Assert.IsTrue(info.ParsingFailed);
}

[TestMethod]
Expand Down

0 comments on commit de88b01

Please sign in to comment.