mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-09-15 22:01:23 +00:00
Don't materialise the whole split list
This should avoid allocating slightly less memory *in some cases*. I dare say there's still ways to OOM here. But also, if you want to OOM the server, you don't need to place a sign to do it! Closes #2365.
This commit is contained in:
+2
-2
@@ -230,11 +230,11 @@ public class TurtlePlaceCommand implements TurtleCommand {
|
||||
}
|
||||
|
||||
private static void setSignText(Level world, SignBlockEntity sign, String message) {
|
||||
var lines = Splitter.on('\n').splitToList(message);
|
||||
var lines = Splitter.on('\n').splitToStream(message).limit(4).toList();
|
||||
var firstLine = lines.size() <= 2 ? 1 : 0;
|
||||
|
||||
var signText = new SignText();
|
||||
for (int i = 0, len = Math.min(lines.size(), 4); i < len; i++) {
|
||||
for (int i = 0, len = lines.size(); i < len; i++) {
|
||||
var line = lines.get(i);
|
||||
signText = signText.setMessage(i + firstLine, line.length() > 15
|
||||
? Component.literal(line.substring(0, 15))
|
||||
|
||||
Reference in New Issue
Block a user