@@ -164,18 +164,18 @@ private[streams] trait Strategies
164164 false
165165 }
166166
167- def isStreamSafe = {
168- // Note: we count the number of closures / ops that have side effects, not the
169- // number of side-effects themselves: we assume that within a closure the
170- // side effects are still done in the same order, and likewise for preserved
171- // sub-trees that they're still evaluated in the same order within the same
172- // originating op. For instance with mkString(prefix, sep, suffix), prefix,
173- // sep and suffix will still be evaluated in the same order after the rewrite.
174- val unsafeClosureSideEffectCount =
175- stream.closureSideEffectss.count(hasUnsafeEffect)
176- def unsafePreservedTreesSideEffectsCount =
177- stream.preservedSubTreesSideEffectss.count(hasUnsafeEffect)
167+ // Note: we count the number of closures / ops that have side effects, not the
168+ // number of side-effects themselves: we assume that within a closure the
169+ // side effects are still done in the same order, and likewise for preserved
170+ // sub-trees that they're still evaluated in the same order within the same
171+ // originating op. For instance with mkString(prefix, sep, suffix), prefix,
172+ // sep and suffix will still be evaluated in the same order after the rewrite.
173+ val unsafeClosureSideEffectCount =
174+ stream.closureSideEffectss.count(hasUnsafeEffect)
175+ def unsafePreservedTreesSideEffectsCount =
176+ stream.preservedSubTreesSideEffectss.count(hasUnsafeEffect)
178177
178+ def isStreamSafe = {
179179 unsafeClosureSideEffectCount <= 1 &&
180180 (unsafeClosureSideEffectCount + unsafePreservedTreesSideEffectsCount) <= 1 &&
181181 ! couldSkipSideEffects
@@ -205,7 +205,22 @@ private[streams] trait Strategies
205205 }
206206 }
207207
208- // println(s"tree = ${stream.tree}\n\tstream = ${stream.describe()}\n\tstrategy = $strategy\n\tlambdaCount = ${stream.lambdaCount}\n\tclosureSideEffectss = ${stream.closureSideEffectss}\n\tcouldSkipSideEffects = $couldSkipSideEffects\n\thasMoreThanOneLambdaWithUnsafeSideEffect = $hasMoreThanOneLambdaWithUnsafeSideEffect\n\tisWorthOptimizing = $worthOptimizing")
208+ // if (flags.debug) {
209+ // // info(stream.tree.pos,
210+ // println(s"""
211+ // tree = ${stream.tree}
212+ // stream = ${stream.describe()}
213+ // strategy = $strategy
214+ // lambdaCount = ${stream.lambdaCount}
215+ // closureSideEffectss = ${stream.closureSideEffectss}
216+ // couldSkipSideEffects = $couldSkipSideEffects
217+ // isWorthOptimizing = $worthOptimizing
218+ // isFaster = $isFaster
219+ // unsafeClosureSideEffectCount = $unsafeClosureSideEffectCount
220+ // unsafePreservedTreesSideEffectsCount = $unsafePreservedTreesSideEffectsCount
221+ // isStreamSafe = $isStreamSafe
222+ // """)//, force = true)
223+ // }
209224
210225 worthOptimizing
211226 }
0 commit comments