lojix/wam_prolog/src/main/com/thesett/aima/logic/fol/wam/optimizer/WAMOptimizer.java
private SizeableList<WAMInstruction> optimize(List<WAMInstruction> instructions)
    {
        StateMachine optimizeConstants = new OptimizeInstructions(symbolTable, interner);
        Iterable<WAMInstruction> matcher =
            new Matcher<WAMInstruction, WAMInstruction>(instructions.iterator(), optimizeConstants);

        SizeableList<WAMInstruction> result = new SizeableLinkedList<WAMInstruction>();

        for (WAMInstruction instruction : matcher)
        {
            result.add(instruction);
        }

        return result;
    }
private SizeableList<WAMInstruction> optimize(List<WAMInstruction> instructions)
    {
        StateMachine optimizeConstants = new OptimizeInstructions(symbolTable, interner);
        Iterable<WAMInstruction> matcher =
            new Matcher<WAMInstruction, WAMInstruction>(instructions.iterator(), optimizeConstants);

        SizeableList<WAMInstruction> result = new SizeableLinkedList<WAMInstruction>();

        for (WAMInstruction instruction : matcher)
        {
            result.add(instruction);
        }

        return result;
    }
private SizeableList < WAMInstruction > optimize ( List < WAMInstruction > instructions ) { StateMachine optimizeConstants = new OptimizeInstructions ( symbolTable , interner ) ; Iterable < WAMInstruction > matcher = new Matcher < WAMInstruction , WAMInstruction > ( instructions . iterator ( ) , optimizeConstants ) ; SizeableList < WAMInstruction > result = new SizeableLinkedList < WAMInstruction > ( ) ; for ( WAMInstruction instruction : matcher ) { result . add ( instruction ) ; } return result ; }
Performs an optimization pass for specialized instructions.

<p/>The following instruction sequences can be optimized:

<pre>
unify_var Xi, get_struc a/0, Xi -> unify_const a/0
get_struc a/0, Xi -> get_const a/0
put_struc a/0, Xi, set_var Xi -> set_const a/0
put_struc a/0, Xi -> put_const a/0
</pre>

@param  instructions The instructions to optimize.

@return An list of optimized instructions.
Performs an optimization pass for specialized instructions .