mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
python: improve code
according to alert and reviewer's suggestion
This commit is contained in:
@@ -23,15 +23,17 @@ class ExprParent_ extends @py_expr_parent {
|
|||||||
* New kinds have been inserted such that
|
* New kinds have been inserted such that
|
||||||
* `@py_Name` which used to have index 18 now has index 19.
|
* `@py_Name` which used to have index 18 now has index 19.
|
||||||
* Entries with lower indices are unchanged.
|
* Entries with lower indices are unchanged.
|
||||||
|
*
|
||||||
|
* Note that if `18 <= new_index < 19`, it does not correspond
|
||||||
|
* to an old index.
|
||||||
*/
|
*/
|
||||||
bindingset[new_index]
|
bindingset[new_index]
|
||||||
int old_index(int new_index) {
|
int old_index(int new_index) {
|
||||||
if new_index < 18
|
// before inserted range
|
||||||
then result = new_index
|
new_index < 18 and result = new_index
|
||||||
else
|
or
|
||||||
if new_index >= 19
|
// after inserted range
|
||||||
then result + (19 - 18) = new_index
|
new_index >= 19 and result + (19 - 18) = new_index
|
||||||
else none()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The schema for py_exprs is:
|
// The schema for py_exprs is:
|
||||||
|
|||||||
@@ -23,15 +23,17 @@ class StmtList_ extends @py_stmt_list {
|
|||||||
* New kinds have been inserted such that
|
* New kinds have been inserted such that
|
||||||
* `@py_Nonlocal` which used to have index 14 now has index 16.
|
* `@py_Nonlocal` which used to have index 14 now has index 16.
|
||||||
* Entries with lower indices are unchanged.
|
* Entries with lower indices are unchanged.
|
||||||
|
*
|
||||||
|
* Note that if `14 <= new_index < 16`, it does not correspond
|
||||||
|
* to an old index.
|
||||||
*/
|
*/
|
||||||
bindingset[new_index]
|
bindingset[new_index]
|
||||||
int old_index(int new_index) {
|
int old_index(int new_index) {
|
||||||
if new_index < 14
|
// before inserted range
|
||||||
then result = new_index
|
new_index < 14 and result = new_index
|
||||||
else
|
or
|
||||||
if new_index >= 16
|
// after inserted range
|
||||||
then result + (16 - 14) = new_index
|
new_index >= 16 and result + (16 - 14) = new_index
|
||||||
else none()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The schema for py_stmts is:
|
// The schema for py_stmts is:
|
||||||
|
|||||||
Reference in New Issue
Block a user