Skip to content

Commit 1867e54

Browse files
Optimize hasAttribute to avoid unnecessary list allocation (#222)
* Initial plan * Optimize hasAttribute to use List.exists instead of filterAttributes Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com> * Remove obsolete sm comment before hasAttribute Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
1 parent f8f7378 commit 1867e54

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/cil.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,9 +1425,8 @@ and dropAttributes (anl: string list) (al: attributes) =
14251425
and filterAttributes (s: string) (al: attribute list) : attribute list =
14261426
List.filter (fun (Attr(an, _)) -> an = s) al
14271427

1428-
(* sm: *)
14291428
let hasAttribute s al =
1430-
(filterAttributes s al <> [])
1429+
List.exists (fun (Attr(an, _)) -> an = s) al
14311430

14321431

14331432
type attributeClass =

0 commit comments

Comments
 (0)