Skip to content

Commit

Permalink
io: Improve wrapper-stream dispatch performance
Browse files Browse the repository at this point in the history
Methods on subclasses of <wrapper-stream> often make heavy use of
inner-stream, which is an open generic function. To ensure that calls
to inner-stream are dispatched efficiently, this change adds sealing
definitions for inner-stream on <wrapper-stream> subclasses.

* sources/io/streams/wrapper-stream.dylan
  (inner-stream on <wrapper-stream>): Make method inline due to its
   simplicity and performance benefit.

* sources/io/streams/indenting-streams.dylan:
  Seal inner-stream on <indenting-stream>.

* sources/lib/coloring-stream/coloring-stream.dylan:
  Seal inner-stream on <coloring-stream>.

* sources/lib/progress-stream/progress-stream.dylan:
  Seal inner-stream on <progress-stream>.

* sources/lib/llvm/bitcode.dylan: Seal inner-stream on
  <bitcode-stream>.
  • Loading branch information
housel committed Jun 20, 2024
1 parent 3398f64 commit def1232
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions sources/io/streams/indenting-streams.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ end;

define sealed domain make(singleton(<indenting-stream>));
define sealed domain initialize(<indenting-stream>);
define sealed domain inner-stream(<indenting-stream>);

define constant $spaces :: <byte-string>
= " "; // 64
Expand Down
2 changes: 1 addition & 1 deletion sources/io/streams/wrapper-stream.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ define sealed domain unlock-stream (<simple-wrapper-stream>);
define open generic inner-stream
(wrapper-stream :: <wrapper-stream>) => (stream :: <stream>);

define method inner-stream
define inline method inner-stream
(wrapper-stream :: <wrapper-stream>) => (stream :: <stream>)
wrapper-stream.%inner-stream;
end method inner-stream;
Expand Down
1 change: 1 addition & 0 deletions sources/lib/coloring-stream/coloring-stream.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ end class <coloring-stream>;

define sealed domain make(singleton(<coloring-stream>));
define sealed domain initialize(<coloring-stream>);
define sealed domain inner-stream(<coloring-stream>);

define sealed method make
(class == <coloring-stream>, #rest initargs,
Expand Down
2 changes: 2 additions & 0 deletions sources/lib/llvm/bitcode.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ define class <bitcode-stream> (<wrapper-stream>)
slot bitcode-records :: <object-table> = make(<object-table>);
end class;

define sealed domain inner-stream (<bitcode-stream>);

define method bitcode-flush
(stream :: <bitcode-stream>)
=> ();
Expand Down
2 changes: 2 additions & 0 deletions sources/lib/progress-stream/progress-stream.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ define sealed method make
end if
end method;

define sealed domain inner-stream (<progress-stream>);

define class <dummy-progress-stream> (<progress-stream>)
end class;

Expand Down

0 comments on commit def1232

Please sign in to comment.