8155581: jshell tool: replace use of Option.get()
Reviewed-by: rfield
This commit is contained in:
parent
b5cd26324b
commit
b2d09f5c6c
@ -1426,18 +1426,15 @@ public class JShellTool implements MessageHandler {
|
||||
live = false;
|
||||
if (!replayableHistory.isEmpty()) {
|
||||
// Prevent history overflow by calculating what will fit, starting
|
||||
// with must recent
|
||||
// with most recent
|
||||
int sepLen = RECORD_SEPARATOR.length();
|
||||
int length = 0;
|
||||
int first = replayableHistory.size();
|
||||
while(length < Preferences.MAX_VALUE_LENGTH && --first >= 0) {
|
||||
length += replayableHistory.get(first).length() + sepLen;
|
||||
}
|
||||
String hist = replayableHistory
|
||||
.subList(first + 1, replayableHistory.size())
|
||||
.stream()
|
||||
.reduce( (a, b) -> a + RECORD_SEPARATOR + b)
|
||||
.get();
|
||||
String hist = String.join(RECORD_SEPARATOR,
|
||||
replayableHistory.subList(first + 1, replayableHistory.size()));
|
||||
prefs.put(REPLAY_RESTORE_KEY, hist);
|
||||
}
|
||||
fluffmsg("jshell.msg.goodbye");
|
||||
|
Loading…
x
Reference in New Issue
Block a user