Skip to content

[C] Improving performance of my Linux kernel query #16903

Closed Answered by smowton
kees asked this question in Q&A
Discussion options

You must be logged in to vote

This may be because you have variables add, array and index that is only bound on one side of the or. On the other side it would be populated by every array indexing operation / every add operation in the kernel, then ultimately the unused variables are ignored, so depending on optimisation choices you may or may not pay a substantial cost for that.

Suggested rewrite:

import cpp

class TrailingSizeOneArrayMember extends Field {
  TrailingSizeOneArrayMember() {
    exists(Struct s |
      this = s.getCanonicalMember(max(int j | s.getCanonicalMember(j) instanceof Field | j))
    ) and
    this.getUnspecifiedType() instanceof ArrayType and
    this.getUnspecifiedType().(ArrayType).getArraySize(

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kees
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants