Determine whether this input channel is at a strictly later point than the other one
| 406 | |
| 407 | // Determine whether this input channel is at a strictly later point than the other one |
| 408 | bool GCodeBuffer::IsLaterThan(const GCodeBuffer& other) const noexcept |
| 409 | { |
| 410 | unsigned int ourDepth = GetStackDepth(); |
| 411 | if (ourDepth == 0 && !machineState->DoingFile()) |
| 412 | { |
| 413 | // This input is not executing from file, so treat it as having advanced past any sync points already |
| 414 | return true; |
| 415 | } |
| 416 | |
| 417 | unsigned int otherDepth = other.GetStackDepth(); |
| 418 | const GCodeMachineState *ourState = machineState; |
| 419 | const GCodeMachineState *otherState = other.machineState; |
| 420 | while (ourDepth > otherDepth) |
| 421 | { |
| 422 | ourState = ourState->GetPrevious(); |
| 423 | --ourDepth; |
| 424 | } |
| 425 | while (otherDepth > ourDepth) |
| 426 | { |
| 427 | otherState = otherState->GetPrevious(); |
| 428 | --otherDepth; |
| 429 | } |
| 430 | |
| 431 | bool oursIsLater = false; |
| 432 | while (ourState != nullptr) |
| 433 | { |
| 434 | if (ourState->fpos > otherState->fpos) |
| 435 | { |
| 436 | oursIsLater = true; |
| 437 | } |
| 438 | else if (ourState->fpos < otherState->fpos) |
| 439 | { |
| 440 | oursIsLater = false; |
| 441 | } |
| 442 | otherState = otherState->GetPrevious(); |
| 443 | ourState = ourState->GetPrevious(); |
| 444 | } |
| 445 | |
| 446 | return oursIsLater; |
| 447 | } |
| 448 | |
| 449 | #endif |
| 450 |
no test coverage detected