summaryrefslogtreecommitdiff
path: root/rules
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-05-24 11:40:46 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-05-24 15:13:56 +0200
commit2681a4b826e9b5bd3db3482bf491348084a1df64 (patch)
treeb44085cc1d92ba83dc33c454e05280a9ebca796a /rules
parentaf9a4c74e28d188e610f345065a9c78bb81ba9b2 (diff)
downloadjustbuild-2681a4b826e9b5bd3db3482bf491348084a1df64.tar.gz
Prefer built-in array access over implementing "first" and "last" using foldl
Diffstat (limited to 'rules')
-rw-r--r--rules/CC/auto/EXPRESSIONS24
1 files changed, 2 insertions, 22 deletions
diff --git a/rules/CC/auto/EXPRESSIONS b/rules/CC/auto/EXPRESSIONS
index ac19f7a0..95209758 100644
--- a/rules/CC/auto/EXPRESSIONS
+++ b/rules/CC/auto/EXPRESSIONS
@@ -1,32 +1,12 @@
{ "last_list_entry":
{ "vars": ["list"]
, "expression":
- { "type": "foldl"
- , "range": {"type": "var", "name": "list"}
- , "start": null
- , "body": {"type": "var", "name": "_"}
- }
+ {"type": "[]", "index": -1, "list": {"type": "var", "name": "list"}}
}
, "first_list_entry":
{ "vars": ["list"]
, "imports": {"last": "last_list_entry"}
, "expression":
- { "type": "let*"
- , "bindings":
- [ [ "list"
- , { "type": "foldl"
- , "range": {"type": "var", "name": "list", "default": []}
- , "start": null
- , "body":
- { "type": "if"
- , "cond": {"type": "var", "name": "$1"}
- , "then": {"type": "var", "name": "$1"}
- , "else": [{"type": "var", "name": "_"}]
- }
- }
- ]
- ]
- , "body": {"type": "CALL_EXPRESSION", "name": "last"}
- }
+ {"type": "[]", "index": 0, "list": {"type": "var", "name": "list"}}
}
}