From 6b45ec53827c2e2938b697fb55de9f158dce295a Mon Sep 17 00:00:00 2001 From: Nicholas Armstrong Date: Sat, 14 Sep 2024 09:04:07 -0400 Subject: [PATCH 01/12] first draft --- .../edu/wpi/first/wpilibj2/command/Command.java | 17 +++++++++++++++++ .../main/native/cpp/frc2/command/Command.cpp | 4 ++++ .../main/native/cpp/frc2/command/CommandPtr.cpp | 7 +++++++ .../main/native/include/frc2/command/Command.h | 17 +++++++++++++++++ .../native/include/frc2/command/CommandPtr.h | 13 +++++++++++++ 5 files changed, 58 insertions(+) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index a53d792d0e4..f895b0d791a 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -398,6 +398,23 @@ public ProxyCommand asProxy() { return new ProxyCommand(this); } + /** + * Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this for + * "forking off" from command compositions when the user does not wish to extend the command's + * requirements to the entire command composition. Note that if run from a composition, + * the composition will not know about the + * status of the scheduled commands, and will treat this command as finishing instantly. + * + * @return the decorated command + * @see ScheduleCommand + * @see WPILib + * docs + */ + public ScheduleCommand fork() { + return new ScheduleCommand(this); + } + /** * Decorates this command to only run if this condition is not met. If the command is already * running and the condition changes to true, the command will not stop running. The requirements diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp index ff5e8f6aa51..bd401a6825b 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp @@ -120,6 +120,10 @@ CommandPtr Command::AsProxy() && { return std::move(*this).ToPtr().AsProxy(); } +CommandPtr Command::Fork() && { + return std::move(*this).ToPtr().Fork(); +} + CommandPtr Command::Unless(std::function condition) && { return std::move(*this).ToPtr().Unless(std::move(condition)); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp index ee7182a7847..92784880997 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp @@ -15,6 +15,7 @@ #include "frc2/command/PrintCommand.h" #include "frc2/command/ProxyCommand.h" #include "frc2/command/RepeatCommand.h" +#include "frc2/command/ScheduleCommand.h" #include "frc2/command/SequentialCommandGroup.h" #include "frc2/command/WaitCommand.h" #include "frc2/command/WaitUntilCommand.h" @@ -53,6 +54,12 @@ CommandPtr CommandPtr::AsProxy() && { return std::move(*this); } +CommandPtr CommandPtr::Fork() && { + AssertValid(); + m_ptr = std::make_unique(std::move(m_ptr)); + return std::move(*this); +} + class RunsWhenDisabledCommand : public WrapperCommand { public: RunsWhenDisabledCommand(std::unique_ptr&& command, diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index c4af1afe81b..d7d17eaec84 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -285,6 +285,23 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { [[nodiscard]] CommandPtr AsProxy() &&; + /** + * Decorates this command to run "forked" by wrapping it in a ScheduleCommand. + * Use this for "forking off" from command compositions when the user does not + * wish to extend the command's requirements to the entire command + * composition. Note that if run from a composition, the composition will not know about the + * status of the scheduled commands, and will treat this command as finishing instantly, see WPILib + * docs for a full explanation. + * + *

This overload transfers command ownership to the returned CommandPtr. + * + * @return the decorated command + * @see ScheduleCommand + */ + [[nodiscard]] + CommandPtr Fork() &&; + /** * Decorates this command to only run if this condition is not met. If the * command is already running and the condition changes to true, the command diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h index e2f534f7547..6e3f1b73ef2 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h @@ -63,6 +63,19 @@ class CommandPtr final { [[nodiscard]] CommandPtr AsProxy() &&; + /** + * Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this for + * "forking off" from command compositions when the user does not wish to extend the command's + * requirements to the entire command composition. Note that if run from a composition, + * the composition will not know about the + * status of the scheduled commands, and will treat this command as finishing instantly. + * + * @return the decorated command + * @see ScheduleCommand + */ + [[nodiscard]] + CommandPtr Fork() &&; + /** * Decorates this command to run or stop when disabled. * From 1fb92f0007b3b71916502e17299012f9d2e73ad6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Sep 2024 03:09:31 +0000 Subject: [PATCH 02/12] Formatting fixes --- .../edu/wpi/first/wpilibj2/command/Command.java | 12 ++++++------ .../src/main/native/include/frc2/command/Command.h | 7 ++++--- .../main/native/include/frc2/command/CommandPtr.h | 13 +++++++------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index f895b0d791a..10974f45b11 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -399,11 +399,11 @@ public ProxyCommand asProxy() { } /** - * Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this for - * "forking off" from command compositions when the user does not wish to extend the command's - * requirements to the entire command composition. Note that if run from a composition, - * the composition will not know about the - * status of the scheduled commands, and will treat this command as finishing instantly. + * Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this + * for "forking off" from command compositions when the user does not wish to extend the command's + * requirements to the entire command composition. Note that if run from a composition, the + * composition will not know about the status of the scheduled commands, and will treat this + * command as finishing instantly. * * @return the decorated command * @see ScheduleCommand @@ -413,7 +413,7 @@ public ProxyCommand asProxy() { */ public ScheduleCommand fork() { return new ScheduleCommand(this); - } + } /** * Decorates this command to only run if this condition is not met. If the command is already diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index d7d17eaec84..453b7f11251 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -289,8 +289,9 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { * Decorates this command to run "forked" by wrapping it in a ScheduleCommand. * Use this for "forking off" from command compositions when the user does not * wish to extend the command's requirements to the entire command - * composition. Note that if run from a composition, the composition will not know about the - * status of the scheduled commands, and will treat this command as finishing instantly, see WPILib * docs for a full explanation. * @@ -300,7 +301,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { * @see ScheduleCommand */ [[nodiscard]] - CommandPtr Fork() &&; + CommandPtr Fork() &&; /** * Decorates this command to only run if this condition is not met. If the diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h index 6e3f1b73ef2..17fa93c8b3a 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h @@ -64,17 +64,18 @@ class CommandPtr final { CommandPtr AsProxy() &&; /** - * Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this for - * "forking off" from command compositions when the user does not wish to extend the command's - * requirements to the entire command composition. Note that if run from a composition, - * the composition will not know about the - * status of the scheduled commands, and will treat this command as finishing instantly. + * Decorates this command to run "forked" by wrapping it in a {@link + * ScheduleCommand}. Use this for "forking off" from command compositions when + * the user does not wish to extend the command's requirements to the entire + * command composition. Note that if run from a composition, the composition + * will not know about the status of the scheduled commands, and will treat + * this command as finishing instantly. * * @return the decorated command * @see ScheduleCommand */ [[nodiscard]] - CommandPtr Fork() &&; + CommandPtr Fork() &&; /** * Decorates this command to run or stop when disabled. From 2952b47fdcd1183a39f4c25576ab4f4763ab0fcf Mon Sep 17 00:00:00 2001 From: Nicholas Armstrong Date: Sat, 14 Sep 2024 23:22:29 -0400 Subject: [PATCH 03/12] fix Java argument requirements --- .../java/edu/wpi/first/wpilibj2/command/Command.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index f895b0d791a..233c35b661a 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -404,15 +404,22 @@ public ProxyCommand asProxy() { * requirements to the entire command composition. Note that if run from a composition, * the composition will not know about the * status of the scheduled commands, and will treat this command as finishing instantly. + * Commands can be added to this and will be scheduled in order with this command scheduled first. * + * @param commands other commands to schedule along with this one. This command is scheduled first * @return the decorated command * @see ScheduleCommand * @see WPILib * docs */ - public ScheduleCommand fork() { - return new ScheduleCommand(this); + public ScheduleCommand fork(Command... other) { + Command[] commands = new Command[1 + other.length]; + commands[0] = this; + for(int i = 1; i < commands.length; i++){ + commands[i] = other[i - 1]; + } + return new ScheduleCommand(commands); } /** From 0ed013f030349854579781eb2208106baee2c712 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Sep 2024 03:31:45 +0000 Subject: [PATCH 04/12] Formatting fixes --- .../wpi/first/wpilibj2/command/Command.java | 20 +++++++++---------- .../native/include/frc2/command/Command.h | 5 +++-- .../native/include/frc2/command/CommandPtr.h | 11 +++++----- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 233c35b661a..180243e295c 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -399,14 +399,14 @@ public ProxyCommand asProxy() { } /** - * Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this for - * "forking off" from command compositions when the user does not wish to extend the command's - * requirements to the entire command composition. Note that if run from a composition, - * the composition will not know about the - * status of the scheduled commands, and will treat this command as finishing instantly. - * Commands can be added to this and will be scheduled in order with this command scheduled first. - * - * @param commands other commands to schedule along with this one. This command is scheduled first + * Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this + * for "forking off" from command compositions when the user does not wish to extend the command's + * requirements to the entire command composition. Note that if run from a composition, the + * composition will not know about the status of the scheduled commands, and will treat this + * command as finishing instantly. Commands can be added to this and will be scheduled in order + * with this command scheduled first. + * + * @param commands other commands to schedule along with this one. This command is scheduled first * @return the decorated command * @see ScheduleCommand * @see { * Decorates this command to run "forked" by wrapping it in a ScheduleCommand. * Use this for "forking off" from command compositions when the user does not * wish to extend the command's requirements to the entire command - * composition. Note that if run from a composition, the composition will not know about the - * status of the scheduled commands, and will treat this command as finishing instantly, see WPILib * docs for a full explanation. * diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h index 825031e0886..17fa93c8b3a 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h @@ -64,11 +64,12 @@ class CommandPtr final { CommandPtr AsProxy() &&; /** - * Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this for - * "forking off" from command compositions when the user does not wish to extend the command's - * requirements to the entire command composition. Note that if run from a composition, - * the composition will not know about the - * status of the scheduled commands, and will treat this command as finishing instantly. + * Decorates this command to run "forked" by wrapping it in a {@link + * ScheduleCommand}. Use this for "forking off" from command compositions when + * the user does not wish to extend the command's requirements to the entire + * command composition. Note that if run from a composition, the composition + * will not know about the status of the scheduled commands, and will treat + * this command as finishing instantly. * * @return the decorated command * @see ScheduleCommand From 883c761cdc2460608b01afadfb5ac2302fb6b1e8 Mon Sep 17 00:00:00 2001 From: Nicholas Armstrong Date: Sat, 14 Sep 2024 23:38:06 -0400 Subject: [PATCH 05/12] missing period --- .../src/main/java/edu/wpi/first/wpilibj2/command/Command.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 233c35b661a..7ca08af1dd2 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -406,7 +406,7 @@ public ProxyCommand asProxy() { * status of the scheduled commands, and will treat this command as finishing instantly. * Commands can be added to this and will be scheduled in order with this command scheduled first. * - * @param commands other commands to schedule along with this one. This command is scheduled first + * @param commands other commands to schedule along with this one. This command is scheduled first. * @return the decorated command * @see ScheduleCommand * @see Date: Sat, 14 Sep 2024 23:39:03 -0400 Subject: [PATCH 06/12] removed C++ for now --- .../main/native/cpp/frc2/command/CommandPtr.cpp | 6 ------ .../main/native/include/frc2/command/CommandPtr.h | 14 -------------- 2 files changed, 20 deletions(-) diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp index 92784880997..47e0515154b 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp @@ -54,12 +54,6 @@ CommandPtr CommandPtr::AsProxy() && { return std::move(*this); } -CommandPtr CommandPtr::Fork() && { - AssertValid(); - m_ptr = std::make_unique(std::move(m_ptr)); - return std::move(*this); -} - class RunsWhenDisabledCommand : public WrapperCommand { public: RunsWhenDisabledCommand(std::unique_ptr&& command, diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h index 17fa93c8b3a..e2f534f7547 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h @@ -63,20 +63,6 @@ class CommandPtr final { [[nodiscard]] CommandPtr AsProxy() &&; - /** - * Decorates this command to run "forked" by wrapping it in a {@link - * ScheduleCommand}. Use this for "forking off" from command compositions when - * the user does not wish to extend the command's requirements to the entire - * command composition. Note that if run from a composition, the composition - * will not know about the status of the scheduled commands, and will treat - * this command as finishing instantly. - * - * @return the decorated command - * @see ScheduleCommand - */ - [[nodiscard]] - CommandPtr Fork() &&; - /** * Decorates this command to run or stop when disabled. * From 256dc211bf6884d9d3a9b3b708b6acaa8d7235aa Mon Sep 17 00:00:00 2001 From: Nicholas Armstrong Date: Sat, 14 Sep 2024 23:45:17 -0400 Subject: [PATCH 07/12] fully remove c++ for now. --- .../main/native/cpp/frc2/command/Command.cpp | 4 ---- .../main/native/include/frc2/command/Command.h | 18 ------------------ 2 files changed, 22 deletions(-) diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp index bd401a6825b..ff5e8f6aa51 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp @@ -120,10 +120,6 @@ CommandPtr Command::AsProxy() && { return std::move(*this).ToPtr().AsProxy(); } -CommandPtr Command::Fork() && { - return std::move(*this).ToPtr().Fork(); -} - CommandPtr Command::Unless(std::function condition) && { return std::move(*this).ToPtr().Unless(std::move(condition)); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index 453b7f11251..c4af1afe81b 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -285,24 +285,6 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { [[nodiscard]] CommandPtr AsProxy() &&; - /** - * Decorates this command to run "forked" by wrapping it in a ScheduleCommand. - * Use this for "forking off" from command compositions when the user does not - * wish to extend the command's requirements to the entire command - * composition. Note that if run from a composition, the composition will not - * know about the status of the scheduled commands, and will treat this - * command as finishing instantly, see WPILib - * docs for a full explanation. - * - *

This overload transfers command ownership to the returned CommandPtr. - * - * @return the decorated command - * @see ScheduleCommand - */ - [[nodiscard]] - CommandPtr Fork() &&; - /** * Decorates this command to only run if this condition is not met. If the * command is already running and the condition changes to true, the command From 9a684d672d52d5d6ce90bacd9cae28c3871daaf7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Sep 2024 03:54:55 +0000 Subject: [PATCH 08/12] Formatting fixes --- .../src/main/java/edu/wpi/first/wpilibj2/command/Command.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index c952920714e..ffda1476d83 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -406,7 +406,8 @@ public ProxyCommand asProxy() { * command as finishing instantly. Commands can be added to this and will be scheduled in order * with this command scheduled first. * - * @param commands other commands to schedule along with this one. This command is scheduled first. + * @param commands other commands to schedule along with this one. This command is scheduled + * first. * @return the decorated command * @see ScheduleCommand * @see Date: Sun, 15 Sep 2024 01:01:25 -0400 Subject: [PATCH 09/12] param rename --- .../src/main/java/edu/wpi/first/wpilibj2/command/Command.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index ffda1476d83..110c365e0af 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -406,7 +406,7 @@ public ProxyCommand asProxy() { * command as finishing instantly. Commands can be added to this and will be scheduled in order * with this command scheduled first. * - * @param commands other commands to schedule along with this one. This command is scheduled + * @param other other commands to schedule along with this one. This command is scheduled * first. * @return the decorated command * @see ScheduleCommand From 354020551f5573cbf4629d0f84a351c9a53fef30 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Sep 2024 05:18:25 +0000 Subject: [PATCH 10/12] Formatting fixes --- .../src/main/java/edu/wpi/first/wpilibj2/command/Command.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 110c365e0af..63d66e353fb 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -406,8 +406,7 @@ public ProxyCommand asProxy() { * command as finishing instantly. Commands can be added to this and will be scheduled in order * with this command scheduled first. * - * @param other other commands to schedule along with this one. This command is scheduled - * first. + * @param other other commands to schedule along with this one. This command is scheduled first. * @return the decorated command * @see ScheduleCommand * @see Date: Sun, 15 Sep 2024 01:33:21 -0400 Subject: [PATCH 11/12] fixed loop copy of array --- .../main/java/edu/wpi/first/wpilibj2/command/Command.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 63d66e353fb..94a42c7797e 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -12,6 +12,8 @@ import edu.wpi.first.util.sendable.Sendable; import edu.wpi.first.util.sendable.SendableBuilder; import edu.wpi.first.util.sendable.SendableRegistry; + +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -416,9 +418,7 @@ public ProxyCommand asProxy() { public ScheduleCommand fork(Command... other) { Command[] commands = new Command[1 + other.length]; commands[0] = this; - for (int i = 1; i < commands.length; i++) { - commands[i] = other[i - 1]; - } + System.arraycopy(other, 0, commands, 1, other.length); return new ScheduleCommand(commands); } From 3e5898921c5826ddeee7e6f9bf0bbc6be154004b Mon Sep 17 00:00:00 2001 From: Nicholas Armstrong Date: Sun, 15 Sep 2024 01:40:47 -0400 Subject: [PATCH 12/12] formatting fixes --- .../src/main/java/edu/wpi/first/wpilibj2/command/Command.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 94a42c7797e..ed934b39c3e 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -12,8 +12,6 @@ import edu.wpi.first.util.sendable.Sendable; import edu.wpi.first.util.sendable.SendableBuilder; import edu.wpi.first.util.sendable.SendableRegistry; - -import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Set;