Skip to content

Commit 9bc2ff4

Browse files
committed
pathname: document EagerInitializeExtension rationale
Explain why the module exists (shape cache warning) and the contract for adding/removing lazy memoised ivars on `Pathname` or its mixed-in extensions, per review feedback.
1 parent 3af57b9 commit 9bc2ff4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Library/Homebrew/extend/pathname/eager_initialize_extension.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# typed: strict
22
# frozen_string_literal: true
33

4+
# Eagerly initialises {Pathname}'s lazy memoised ivars so every instance
5+
# shares one object shape, avoiding Ruby's shape-variation warning.
6+
#
7+
# Any new `@x ||= ...` ivar added to {Pathname} or its mixed-in extensions
8+
# must also be added to `#initialize` below to keep the shape stable.
49
module EagerInitializeExtension
510
extend T::Helpers
611

0 commit comments

Comments
 (0)