Skip to main content

Module inline

Module inline 

Source
Expand description

Refactoring and modernization helpers. Subroutine inlining for Perl code.

Provides text-based subroutine inlining that replaces a call site with the function’s body after substituting formal parameters with the actual arguments from the call.

§Limitations

This is a text-pattern implementation. It does not build a full AST and therefore relies on heuristics for:

  • Parameter extraction (assumes my ($a, $b, …) = @_; pattern)
  • Return detection (counts return keywords)
  • Recursion detection (looks for the sub name inside the body)
  • Side-effect detection (looks for print, warn, die, open, close, write, read, seek, sysread, syswrite)

Functions that do not follow these conventions may not be inlined correctly. The safe defaults are to reject when uncertain (recursion, large body, multiple returns) and to warn when side effects are detected.

Structs§

SubInliner
Text-based Perl subroutine inliner.

Enums§

InlineAbility
The result of analysing a subroutine’s inlineability.
InlineError
Error type returned by subroutine inlining operations.

Functions§

analyze_sub_for_inlining
Analyse whether a named subroutine can be inlined.