mirror of
https://github.com/irmen/prog8.git
synced 2024-12-22 18:30:01 +00:00
tweak containment check even more
This commit is contained in:
parent
ac0c8a68f6
commit
cf551d2cc7
@ -149,8 +149,10 @@ internal class VariousCleanups(val program: Program, val errors: IErrorReporter,
|
||||
return listOf(IAstModification.ReplaceNode(expr, compare, parent))
|
||||
}
|
||||
}
|
||||
if(values.size<3)
|
||||
return noModifications // replacement only worthwhile for 3 or more values
|
||||
if(values.size<2)
|
||||
return noModifications
|
||||
|
||||
// replace x==1 or x==2 or x==3 with a containment check x in [1,2,3]
|
||||
val valueCopies = values.sortedBy { it.number }.map { it.copy() }
|
||||
val arrayType = ElementToArrayTypes.getValue(elementType)
|
||||
val valuesArray = ArrayLiteral(InferredTypes.InferredType.known(arrayType), valueCopies.toTypedArray(), expr.position)
|
||||
|
@ -22,5 +22,8 @@ main {
|
||||
|
||||
if w==1313 or w==4242 or w==9999 or w==10101 ; optimize the containment check to not always use an array + jsr
|
||||
txt.print("yep4\n")
|
||||
|
||||
if w==1313 or w==9999 ; optimize the containment check to not always use an array + jsr
|
||||
txt.print("yep5\n")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user