teensy optimizations

This commit is contained in:
David Renshaw 2014-10-01 17:18:19 -04:00
parent ad161e1569
commit 582b0eb54f
2 changed files with 6 additions and 2 deletions

View file

@ -49,11 +49,13 @@ public class CarSales
new Text.Reader("Volt"), new Text.Reader("Accord"),
new Text.Reader("Leaf"), new Text.Reader("Model S")};
static final Color colors[] = Color.values();
static final void randomCar(Common.FastRand rng, Car.Builder car) {
car.setMake(MAKES[rng.nextLessThan(MAKES.length)]);
car.setModel(MODELS[rng.nextLessThan(MODELS.length)]);
car.setColor(Color.values()[rng.nextLessThan(Color.SILVER.ordinal() + 1)]);
car.setColor(colors[rng.nextLessThan(Color.SILVER.ordinal() + 1)]);
car.setSeats((byte)(2 + rng.nextLessThan(6)));
car.setDoors((byte)(2 + rng.nextLessThan(3)));

View file

@ -9,8 +9,10 @@ public class Eval
extends TestCase<Expression.Factory, Expression.Builder, Expression.Reader,
EvaluationResult.Factory, EvaluationResult.Builder, EvaluationResult.Reader, Integer> {
static final Operation operations[] = Operation.values();
public static int makeExpression(Common.FastRand rng, Expression.Builder exp, int depth) {
exp.setOp(Operation.values()[rng.nextLessThan(Operation.MODULUS.ordinal() + 1)]);
exp.setOp(operations[rng.nextLessThan(Operation.MODULUS.ordinal() + 1)]);
int left = 0;
if (rng.nextLessThan(8) < depth) {