• Patrick Bajao's avatar
    Avoid N+1 calls for image_path when rendering commits · 682d744b
    Patrick Bajao authored
    When rendering `projects/commits/commit` partial, it calls some
    helper methods like `sprite_icon` and `clipboard_button`.
    
    These methods call `sprite_icon_path` internally which is not that
    slow (averaging around 6ms per call on my local machine). But when
    called multiple times (e.g. rendering 100 commits), it adds up.
    
    Some benchmark numbers for `Projects::MergeRequestsController#commits`
    (average of 5 requests, with `RAILS_PROFILE` env var set to `true`:
    
    - BEFORE: 1.051528
    - AFTER: 0.684848
    
    This shows around 35% improvement.
    682d744b
209912-memoize-sprites-icon-path.yml 112 Bytes