mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8286163: micro-optimize Instant.plusSeconds
Reviewed-by: scolebourne, redestad, naoto
This commit is contained in:
parent
60a91d15ad
commit
3462190965
2 changed files with 94 additions and 1 deletions
|
@ -878,7 +878,11 @@ public final class Instant
|
|||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
public Instant plusSeconds(long secondsToAdd) {
|
||||
return plus(secondsToAdd, 0);
|
||||
if (secondsToAdd == 0) {
|
||||
return this;
|
||||
}
|
||||
long epochSec = Math.addExact(seconds, secondsToAdd);
|
||||
return create(epochSec, nanos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue