@@ -122,10 +122,10 @@ def pretty_print(q)
122
122
123
123
# Below here are the most common combination of options that are created when
124
124
# creating new breakables. They are here to cut down on some allocations.
125
- BREAKABLE_SPACE = Breakable . new ( " " , 1 , indent : true , force : false )
126
- BREAKABLE_EMPTY = Breakable . new ( "" , 0 , indent : true , force : false )
127
- BREAKABLE_FORCE = Breakable . new ( " " , 1 , indent : true , force : true )
128
- BREAKABLE_RETURN = Breakable . new ( " " , 1 , indent : false , force : true )
125
+ BREAKABLE_SPACE = Breakable . new ( " " , 1 , indent : true , force : false ) . freeze
126
+ BREAKABLE_EMPTY = Breakable . new ( "" , 0 , indent : true , force : false ) . freeze
127
+ BREAKABLE_FORCE = Breakable . new ( " " , 1 , indent : true , force : true ) . freeze
128
+ BREAKABLE_RETURN = Breakable . new ( " " , 1 , indent : false , force : true ) . freeze
129
129
130
130
# A node in the print tree that forces the surrounding group to print out in
131
131
# the "break" mode as opposed to the "flat" mode. Useful for when you need to
@@ -138,7 +138,7 @@ def pretty_print(q)
138
138
139
139
# Since there's really no difference in these instances, just using the same
140
140
# one saves on some allocations.
141
- BREAK_PARENT = BreakParent . new
141
+ BREAK_PARENT = BreakParent . new . freeze
142
142
143
143
# A node in the print tree that represents a group of items which the printer
144
144
# should try to fit onto one line. This is the basic command to tell the
@@ -267,7 +267,7 @@ def pretty_print(q)
267
267
268
268
# Since all of the instances here are the same, we can reuse the same one to
269
269
# cut down on allocations.
270
- TRIM = Trim . new
270
+ TRIM = Trim . new . freeze
271
271
272
272
# When building up the contents in the output buffer, it's convenient to be
273
273
# able to trim trailing whitespace before newlines. If the output object is a
@@ -348,6 +348,7 @@ def self.for(output)
348
348
# behavior (for instance to use tabs) by passing a different genspace
349
349
# procedure.
350
350
DEFAULT_GENSPACE = -> ( n ) { " " * n }
351
+ Ractor . make_shareable ( DEFAULT_GENSPACE ) if defined? ( Ractor )
351
352
352
353
# There are two modes in printing, break and flat. When we're in break mode,
353
354
# any lines will use their newline, any if-breaks will use their break
0 commit comments