[server] Minor refactoring (take 1).

This commit is contained in:
Ciprian Dorin Craciun 2022-08-26 17:18:31 +03:00
parent 94d603ac66
commit 89761ff44e

View file

@ -158,16 +158,12 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () {
var _referencesValues [2]uint64
var _referencesBuffer []byte
var _namespaceAndPathSuffixes = [][2]string {
{NamespaceFilesContent, ""},
{NamespaceRedirectsContent, ""},
{NamespaceFilesContent, "/"},
{NamespaceRedirectsContent, "/"},
{NamespaceFilesContent, "/*"},
{NamespaceRedirectsContent, "/*"},
{NamespaceFoldersContent, ""},
{NamespaceFoldersContent, "/"},
}
var _namespaceAndPathSuffixes [][2]string
if true {
_namespaceAndPathSuffixes = _namespaceAndPathSuffixes_a_static
} else {
_namespaceAndPathSuffixes = _namespaceAndPathSuffixes_b_static
}
if !_referencesFound {
@ -177,8 +173,7 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () {
continue
}
for _namespaceAndPathSuffixIndex := range _namespaceAndPathSuffixes {
_namespaceAndPathSuffix := _namespaceAndPathSuffixes[_namespaceAndPathSuffixIndex]
for _, _namespaceAndPathSuffix := range _namespaceAndPathSuffixes {
_namespace := _namespaceAndPathSuffix[0]
_pathSuffix := _namespaceAndPathSuffix[1]
@ -259,7 +254,7 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () {
_pathLimit >= 0;
_pathLimit = bytes.LastIndexByte (_path[: _pathLimit], '/') {
for _, _namespace := range []string { NamespaceFilesContent, NamespaceRedirectsContent } {
for _, _namespace := range _namespace_c_static {
if _server.cachedReferences != nil {
_key := _keyBufferLarge[:0]
@ -447,6 +442,28 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () {
}
var _namespaceAndPathSuffixes_a_static = [][2]string {
{NamespaceFilesContent, ""},
{NamespaceRedirectsContent, ""},
{NamespaceFoldersContent, ""},
}
var _namespaceAndPathSuffixes_b_static = [][2]string {
{NamespaceFilesContent, ""},
{NamespaceRedirectsContent, ""},
{NamespaceFilesContent, "/"},
{NamespaceRedirectsContent, "/"},
{NamespaceFilesContent, "/*"},
{NamespaceRedirectsContent, "/*"},
{NamespaceFoldersContent, ""},
{NamespaceFoldersContent, "/"},
}
var _namespace_c_static = []string {
NamespaceFilesContent,
NamespaceRedirectsContent,
}
func (_server *server) ServeStatic (_context *fasthttp.RequestCtx, _status uint, _data []byte, _contentType string, _contentEncoding string, _cache bool) () {