Remove use of ToLower to reduce memory copies
RequestInfo always have lowercase strings in it, so no need to
lower case or casefold compare anything.
@@ -4,7 +4,6 @@ import (
"bytes"
"io/ioutil"
"net/http"
- "strings"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/endpoints/request"
@@ -42,10 +41,10 @@ func (a *personalSARRequestInfoResolver) NewRequestInfo(req *http.Request) (*req
case len(requestInfo.Subresource) != 0:
return requestInfo, nil
- case strings.ToLower(requestInfo.Verb) != "create":
+ case requestInfo.Verb != "create":
return requestInfo, nil
- case strings.ToLower(requestInfo.Resource) != "subjectaccessreviews" && strings.ToLower(requestInfo.Resource) != "localsubjectaccessreviews":
+ case requestInfo.Resource != "subjectaccessreviews" && requestInfo.Resource != "localsubjectaccessreviews":
return requestInfo, nil
}
@@ -76,7 +75,7 @@ func isPersonalAccessReviewFromRequest(req *http.Request, requestInfo *request.R
req.Body = ioutil.NopCloser(bytes.NewBuffer(body))
defaultGVK := schema.GroupVersionKind{Version: requestInfo.APIVersion, Group: requestInfo.APIGroup}
- switch strings.ToLower(requestInfo.Resource) {
+ switch requestInfo.Resource {
case "subjectaccessreviews":
defaultGVK.Kind = "SubjectAccessReview"
case "localsubjectaccessreviews":
