From a5859fd54e69d113fdd7f7415bd4d1c0d9b7abd3 Mon Sep 17 00:00:00 2001 From: Peter Boyer Date: Thu, 6 Oct 2016 16:18:18 -0400 Subject: [PATCH] Fix PredictionContext merge() typo (#61) * Fix pred context typo * Adjust array lengths --- runtime/Go/antlr/prediction_context.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/Go/antlr/prediction_context.go b/runtime/Go/antlr/prediction_context.go index 6ec5047f3..4d5932a19 100644 --- a/runtime/Go/antlr/prediction_context.go +++ b/runtime/Go/antlr/prediction_context.go @@ -383,7 +383,7 @@ func merge(a, b PredictionContext, rootIsWildcard bool, mergeCache *DoubleDict) } ac, ok1 := a.(*BaseSingletonPredictionContext) - bc, ok2 := a.(*BaseSingletonPredictionContext) + bc, ok2 := b.(*BaseSingletonPredictionContext) if ok1 && ok2 { return mergeSingletons(ac, bc, rootIsWildcard, mergeCache) @@ -615,8 +615,8 @@ func mergeArrays(a, b *ArrayPredictionContext, rootIsWildcard bool, mergeCache * var j = 0 // walks b var k = 0 // walks target M array - var mergedReturnStates = make([]int, 0) - var mergedParents = make([]PredictionContext, 0) + var mergedReturnStates = make([]int, len(a.returnStates) + len(b.returnStates)) + var mergedParents = make([]PredictionContext, len(a.returnStates) + len(b.returnStates)) // walk and merge to yield mergedParents, mergedReturnStates for i < len(a.returnStates) && j < len(b.returnStates) { var aParent = a.parents[i]