summaryrefslogtreecommitdiffhomepage
path: root/caddy.go
diff options
context:
space:
mode:
authorDominik Braun <[email protected]>2019-08-08 07:59:02 +0200
committerMatt Holt <[email protected]>2019-08-07 23:59:02 -0600
commit4950ce485f7d931890fcfd2ee287b6df1b5db435 (patch)
tree81cafb7b6f235d001c99cc5185118a8490d98458 /caddy.go
parentc8b0a97b1c2524f7486aef38b2cf78a93d7b98b0 (diff)
downloadcaddy-4950ce485f7d931890fcfd2ee287b6df1b5db435.tar.gz
caddy-4950ce485f7d931890fcfd2ee287b6df1b5db435.zip
Part 1: Optimize using compiler's inliner (#2687)
* optimized functions for inlining * added note regarding ResponseWriterWrapper * optimzed browseWrite* methods for FileServer * created benchmarks for comparison * creating browseListing instance in each function * created benchmarks for openResponseWriter * removed benchmarks of old implementations * implemented sync.Pool for byte buffers * using global sync.Pool for writing JSON/HTML
Diffstat (limited to 'caddy.go')
-rw-r--r--caddy.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/caddy.go b/caddy.go
index 5a5349e99..c30eccf77 100644
--- a/caddy.go
+++ b/caddy.go
@@ -208,8 +208,16 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
// If no version information is available, a non-nil
// value will still be returned, but with an
// unknown version.
-func GoModule() debug.Module {
- mod := debug.Module{Version: "unknown"}
+func GoModule() *debug.Module {
+ var mod debug.Module
+ return goModule(&mod)
+}
+
+// goModule holds the actual implementation of GoModule.
+// Allocating debug.Module in GoModule() and passing a
+// reference to goModule enables mid-stack inlining.
+func goModule(mod *debug.Module) *debug.Module {
+ mod.Version = "unknown"
bi, ok := debug.ReadBuildInfo()
if ok {
mod.Path = bi.Main.Path