Short-Circuit Evaluation Optimizer Suggester
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
Short-Circuit Evaluation Optimizer Suggester is a developer-focused tool that analyzes Solidity conditional expressions and suggests optimizations for short-circuit evaluation. It takes contract source code from the user and parses logical operators (&& and ||) in conditional contexts including if statements, require statements, return statements, and ternary operators. The tool evaluates each condition to determine if the left and right sides are ordered optimally for gas efficiency. It considers the cost of evaluating each side of the condition, with a preference for cheaper, simpler checks on the left side for && (AND) and more likely-to-be-true conditions on the left for || (OR). Each suggestion includes the operator, the proposed reordering, the reasoning, and the line number. Results are displayed with a summary showing the total number of conditions and optimizations suggested. This enables developers to reduce gas costs by reordering logical conditions for maximum short-circuit efficiency.
HOW TO USE
Paste your Solidity contract source code into the input area. Click "Suggest optimizations" to analyze the code. The tool will display a summary showing the total number of conditions and the number of optimization suggestions. Each suggestion entry includes the operator, the condition snippets, the suggested optimization, reasoning, and line number. The report can be copied or downloaded as JSON for further analysis.
TECHNICAL NOTE: SHORT-CIRCUIT EVALUATION ANALYSIS
The tool uses regex-based parsing to detect logical operators (&& and ||) in conditional contexts. It extracts the left and right sides of each condition and applies heuristic analysis to determine if the order is optimal. For && (AND), the left side should be the cheaper/easier check to evaluate first, as short-circuit evaluation stops if the left side is false. For || (OR), the left side should be the condition more likely to be true, as short-circuit evaluation stops if the left side is true. The tool also checks require statements and other conditional contexts to identify optimization opportunities. Each suggestion is classified by severity: optimize (definite gas savings) or warn (potential improvement).
WHAT IT CANNOT SEE
The tool cannot automatically detect all optimization opportunities without context; some reorderings may depend on the specific contract logic. It is limited to the accuracy of the source code analysis; syntax variations may cause parsing issues. It cannot detect issues in external contracts or libraries that are imported into the contract. It is limited by the parser's ability to handle Solidity syntax variations, including newer language features. It cannot suggest optimizations for non-EVM chains.
PLEASE NOTE
This tool is designed exclusively for Solidity contracts on EVM-compatible chains. It does not support other smart contract languages. The suggestions are based on static analysis and should be verified with actual usage patterns and testing. The tool is read-only and does not modify any state. The tool provides no warranty that the suggestions are complete or accurate; users are responsible for validating all recommendations.