-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize true/false conditions when coding if-statements
We already had some code which "optimized" some if-statements with one or two conditions, where one or both were constant equal to `true` or `false`. We skipped branches whose condition was always `false`. However, we did not use the `IntrIgnoring` mechanism for that. Thus, such code would still trigger warnings if it contained undefined globals, e.g. gap> f:=function() if false then undefined_global(); fi; end;; Syntax warning: Unbound global variable f:=function() if false then undefined_global(); fi; end;; ^ This can be viewed as a feature, or as a bug, depending on view point. A reason to consider it a "bug" (or at least an undesirable feature) is when using global constants to only conditionally execute code, such as this: if IsHPCGAP then UNLOCK(lock); fi; This code is optimized away in regular GAP, but still triggers a warning during parsing. With this commit, we change how we deal with true/false conditions in if-statements, by making use of the `IntrIgnoring` mechanism. This avoids the warnings about globals in the examples above. It also has the side effect of being "better" at optimizing away branches of an if-statement which can never be executed.
- Loading branch information
1 parent
880bf19
commit 144b52a
Showing
9 changed files
with
194 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.