Merge pull request #203 from RamType0/FixCompletedTaskAsUniTaskAllocating
Suppress allocations around UniTask<T>.AsUniTask and UniTask.AsAsyncUnitUniTaskmaster
commit
9406305b2e
|
@ -115,8 +115,13 @@ namespace Cysharp.Threading.Tasks
|
||||||
var status = this.source.GetStatus(this.token);
|
var status = this.source.GetStatus(this.token);
|
||||||
if (status.IsCompletedSuccessfully())
|
if (status.IsCompletedSuccessfully())
|
||||||
{
|
{
|
||||||
|
this.source.GetResult(this.token);
|
||||||
return CompletedTasks.AsyncUnit;
|
return CompletedTasks.AsyncUnit;
|
||||||
}
|
}
|
||||||
|
else if(this.source is IUniTaskSource<AsyncUnit> asyncUnitSource)
|
||||||
|
{
|
||||||
|
return new UniTask<AsyncUnit>(asyncUnitSource, this.token);
|
||||||
|
}
|
||||||
|
|
||||||
return new UniTask<AsyncUnit>(new AsyncUnitSource(this.source), this.token);
|
return new UniTask<AsyncUnit>(new AsyncUnitSource(this.source), this.token);
|
||||||
}
|
}
|
||||||
|
@ -422,6 +427,7 @@ namespace Cysharp.Threading.Tasks
|
||||||
var status = this.source.GetStatus(this.token);
|
var status = this.source.GetStatus(this.token);
|
||||||
if (status.IsCompletedSuccessfully())
|
if (status.IsCompletedSuccessfully())
|
||||||
{
|
{
|
||||||
|
this.source.GetResult(this.token);
|
||||||
return UniTask.CompletedTask;
|
return UniTask.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue