Skip to content

Move HttpBackend function to Http to reduce function calls when git smart http requests #9057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 21, 2019

Conversation

lunny
Copy link
Member

@lunny lunny commented Nov 18, 2019

Before this change, we always create a closure function when response a smart git http request. This PR moved all codes to function Http to reduce the unnecessary closure function invoke.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Nov 18, 2019
@codecov-io
Copy link

codecov-io commented Nov 18, 2019

Codecov Report

Merging #9057 into master will increase coverage by <.01%.
The diff coverage is 30.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9057      +/-   ##
==========================================
+ Coverage   41.14%   41.14%   +<.01%     
==========================================
  Files         549      549              
  Lines       71506    71507       +1     
==========================================
+ Hits        29418    29423       +5     
  Misses      38365    38365              
+ Partials     3723     3719       -4
Impacted Files Coverage Δ
routers/repo/http.go 35.38% <30.76%> (+0.15%) ⬆️
modules/task/migrate.go 25% <0%> (-3.95%) ⬇️
models/error.go 33.26% <0%> (-0.6%) ⬇️
models/repo.go 45.23% <0%> (+0.04%) ⬆️
modules/migrations/gitea.go 9.45% <0%> (+0.63%) ⬆️
modules/migrations/migrate.go 25.4% <0%> (+1.62%) ⬆️
models/pull_list.go 59.85% <0%> (+2.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51ed4cc...89dc434. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 18, 2019
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 18, 2019
@zeripath
Copy link
Contributor

As far as I was aware in go Closures aren't expensive to run - however this code doesn't need to be a closure (at least not any more - my suspicion is this is left over from some previous router structure).

This refactor makes the HTTP() function even longer and more complex. It's already too complex. We should be moving code out of HTTP() not in to it.

You could simply change the signature of the HTTPBackend to make it be a normal function instead.

@lunny
Copy link
Member Author

lunny commented Nov 19, 2019

@zeripath I moved them back to HTTP to prepare for next refactor PR. Currently we have two routers here, one is Macaron, another is custom regex routers. I think next refactor PR should just use Macaron routers.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 20, 2019
@techknowlogick techknowlogick merged commit d5261b9 into go-gitea:master Nov 21, 2019
@lunny lunny deleted the lunny/remove_httpbackend branch November 18, 2020 04:37
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants