Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • lib
  • flex_array.c
Find file BlameHistoryPermalink
  • Jesse Gross's avatar
    flex_array: avoid divisions when accessing elements · 704f15dd
    Jesse Gross authored May 26, 2011
    
    
    On most architectures division is an expensive operation and accessing an
    element currently requires four of them.  This performance penalty
    effectively precludes flex arrays from being used on any kind of fast
    path.  However, two of these divisions can be handled at creation time and
    the others can be replaced by a reciprocal divide, completely avoiding
    real divisions on access.
    
    [eparis@redhat.com: rebase on top of changes to support 0 len elements]
    [eparis@redhat.com: initialize part_nr when array fits entirely in base]
    Signed-off-by: default avatarJesse Gross <jesse@nicira.com>
    Signed-off-by: default avatarEric Paris <eparis@redhat.com>
    Cc: Dave Hansen <dave@linux.vnet.ibm.com>
    Cc: David Rientjes <rientjes@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    704f15dd
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7