Skip to content

Commit

Permalink
Remove 0-value optimization from Add{Micro,Nano}Seconds
Browse files Browse the repository at this point in the history
Returning early for 0 is only an optimization when passing in a 0.
I estimate that most usages do not that, as why would you call `AddMicroSeconds(0)`.
  • Loading branch information
jnyrup committed Nov 20, 2022
1 parent 7a92a25 commit 868a20b
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions Src/FluentAssertions/Extensions/FluentDateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,6 @@ public static int Nanosecond(this DateTimeOffset self)
/// </summary>
public static DateTime AddNanoseconds(this DateTime self, long nanoseconds)
{
if (nanoseconds == 0)
{
return self;
}

return self + nanoseconds.Nanoseconds();
}

Expand All @@ -270,11 +265,6 @@ public static DateTime AddNanoseconds(this DateTime self, long nanoseconds)
/// </summary>
public static DateTimeOffset AddNanoseconds(this DateTimeOffset self, long nanoseconds)
{
if (nanoseconds == 0)
{
return self;
}

return self + nanoseconds.Nanoseconds();
}

Expand All @@ -299,11 +289,6 @@ public static int Microsecond(this DateTimeOffset self)
/// </summary>
public static DateTime AddMicroseconds(this DateTime self, long microseconds)
{
if (microseconds == 0)
{
return self;
}

return self + microseconds.Microseconds();
}

Expand All @@ -312,11 +297,6 @@ public static DateTime AddMicroseconds(this DateTime self, long microseconds)
/// </summary>
public static DateTimeOffset AddMicroseconds(this DateTimeOffset self, long microseconds)
{
if (microseconds == 0)
{
return self;
}

return self + microseconds.Microseconds();
}

Expand Down

0 comments on commit 868a20b

Please sign in to comment.