Skip to content

Commit 3780045

Browse files
committed
Revert to overhead returns default instead of Unsafe.SkinInit.
1 parent 3c3798f commit 3780045

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

src/BenchmarkDotNet/Toolchains/InProcess/NoEmit/BenchmarkActionFactory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private static void PrepareInstanceAndResultType(
114114
if (isUsingAsyncKeyword)
115115
throw new NotSupportedException("Async void is not supported by design.");
116116
}
117-
else if (resultType.IsByRefLike() || resultType?.GetElementType()?.IsByRefLike() == true)
117+
else if (resultType.IsByRefLike() || resultType.GetElementType()?.IsByRefLike() == true)
118118
{
119119
throw new NotSupportedException("InProcessNoEmitToolchain does not support consuming ByRefLike return types.");
120120
}

src/BenchmarkDotNet/Toolchains/InProcess/NoEmit/BenchmarkActionFactory_Implementations.cs

+4-20
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,9 @@ public BenchmarkAction(object instance, MethodInfo method, int unrollFactor)
184184
InvokeMultiple = InvokeMultipleHardcoded;
185185
}
186186

187-
private static T OverheadStatic()
188-
{
189-
Unsafe.SkipInit(out T value);
190-
return value;
191-
}
187+
private static T OverheadStatic() => default;
192188

193-
private T OverheadInstance()
194-
{
195-
Unsafe.SkipInit(out T value);
196-
return value;
197-
}
189+
private T OverheadInstance() => default;
198190

199191
private void InvokeSingleHardcoded() => consumer.Consume(callback());
200192

@@ -274,11 +266,7 @@ public BenchmarkActionTask(object instance, MethodInfo method, int unrollFactor)
274266
InvokeMultiple = InvokeMultipleHardcoded;
275267
}
276268

277-
private T Overhead()
278-
{
279-
Unsafe.SkipInit(out T value);
280-
return value;
281-
}
269+
private T Overhead() => default;
282270

283271
// must be kept in sync with GenericTaskDeclarationsProvider.TargetMethodDelegate
284272
private T ExecuteBlocking() => startTaskCallback().GetAwaiter().GetResult();
@@ -362,11 +350,7 @@ public BenchmarkActionValueTask(object instance, MethodInfo method, int unrollFa
362350
InvokeMultiple = InvokeMultipleHardcoded;
363351
}
364352

365-
private T Overhead()
366-
{
367-
Unsafe.SkipInit(out T value);
368-
return value;
369-
}
353+
private T Overhead() => default;
370354

371355
// must be kept in sync with GenericTaskDeclarationsProvider.TargetMethodDelegate
372356
private T ExecuteBlocking() => startTaskCallback().GetAwaiter().GetResult();

0 commit comments

Comments
 (0)