Optimize Banzai::Filter::RelativeLinkFilter

What does this MR do?

Optimize Banzai::Filter::RelativeLinkFilter

A lot of git operations were being repeated, for example, to build a url you would ask if the path was a Tree, which would call a recursive routine in Gitlab::Git::Tree#where, then ask if the path was a Blob, which would call a recursive routine at Gitlab::Git::Blob#find, making reference to the same git objects several times. Now we call Rugged::Tree#path, which allows us to determine the type of the path in one pass.

Some other minor improvement added, like saving commonly used references instead of calculating them each time.

Are there points in the code the reviewer needs to double check?


Why was this MR needed?

Banzai::Filter::RelativeLinkFilter is snow

What are the relevant issue numbers?

Closes #18590 (closed)

Screenshots (if relevant)

For testing I prepared a file with many relative (to the current and to the root) paths repeated many times. The requests took the following times:





Does this MR meet the acceptance criteria?

/cc @pcarranza