Merge pull request #157 from RamType-0/OptimizeConsumeEnumerator
Optimize EnumeratorPromise.ConsumeEnumerator while consuming CustomYieldInstructionmaster
commit
4955ed18f1
|
@ -163,11 +163,10 @@ namespace Cysharp.Threading.Tasks
|
||||||
{
|
{
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
else if (current is CustomYieldInstruction)
|
else if (current is CustomYieldInstruction cyi)
|
||||||
{
|
{
|
||||||
// WWW, WaitForSecondsRealtime
|
// WWW, WaitForSecondsRealtime
|
||||||
var e2 = UnwrapWaitCustomYieldInstruction((CustomYieldInstruction)current);
|
while (cyi.keepWaiting)
|
||||||
while (e2.MoveNext())
|
|
||||||
{
|
{
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
@ -212,15 +211,6 @@ namespace Cysharp.Threading.Tasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WWW and others as CustomYieldInstruction.
|
|
||||||
static IEnumerator UnwrapWaitCustomYieldInstruction(CustomYieldInstruction yieldInstruction)
|
|
||||||
{
|
|
||||||
while (yieldInstruction.keepWaiting)
|
|
||||||
{
|
|
||||||
yield return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static readonly FieldInfo waitForSeconds_Seconds = typeof(WaitForSeconds).GetField("m_Seconds", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic);
|
static readonly FieldInfo waitForSeconds_Seconds = typeof(WaitForSeconds).GetField("m_Seconds", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic);
|
||||||
|
|
||||||
static IEnumerator UnwrapWaitForSeconds(WaitForSeconds waitForSeconds)
|
static IEnumerator UnwrapWaitForSeconds(WaitForSeconds waitForSeconds)
|
||||||
|
|
Loading…
Reference in New Issue