Optimizer
scalus.uplc.transform.Optimizer
trait Optimizer
Base trait for UPLC term optimizers.
An optimizer transforms a UPLC (Untyped Plutus Core) term into an equivalent but more efficient term. Optimizers can perform various transformations such as:
- Dead code elimination
- Function inlining and beta-reduction
- Eta-reduction (removing redundant lambda abstractions)
- Constant folding
- Conversion of lazy evaluation to strict evaluation when safe
==Usage==
Optimizers are typically used in optimization pipelines (see V1V2Optimizer and V3Optimizer) where multiple optimization passes are applied sequentially:
val optimizer = new StrictIf()
val optimizedTerm = optimizer(term)
println(s"Optimizations applied: ${optimizer.logs.mkString(", ")}")
==Implementation Notes==
Optimizer implementations should:
- Accept a scalus.uplc.eval.Logger as constructor parameter for logging optimizations
- Be deterministic: applying the same optimizer to the same term should always produce the same result
- Preserve semantics: the optimized term must be equivalent to the original term
- Log all applied optimizations for debugging and analysis
Attributes
- See also
-
StrictIf for lazy-to-strict if-then-else conversion
EtaReduce for eta-reduction optimization
Inliner for function inlining and dead code elimination
ForcedBuiltinsExtractor for extracting forced builtins to top level
CaseConstrApply for optimizing nested Apply with Case/Constr (Plutus V3)
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class CaseConstrApplyclass EtaReduceclass ForcedBuiltinsExtractorclass Inlinerobject NoopOptimizerclass StrictIfclass V1V2Optimizerclass V3Optimizer
Members list
In this article