Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
6c22cff3
Unverified
Commit
6c22cff3
authored
Mar 27, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 27, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75755 from smarterclayton/save_one_allocate
Avoid allocating the watch shim object more than once
parents
f6c51d6e
316a87ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
watch.go
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/watch.go
+3
-1
No files found.
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/watch.go
View file @
6c22cff3
...
@@ -216,6 +216,7 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
...
@@ -216,6 +216,7 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
var
unknown
runtime
.
Unknown
var
unknown
runtime
.
Unknown
internalEvent
:=
&
metav1
.
InternalEvent
{}
internalEvent
:=
&
metav1
.
InternalEvent
{}
outEvent
:=
&
metav1
.
WatchEvent
{}
buf
:=
&
bytes
.
Buffer
{}
buf
:=
&
bytes
.
Buffer
{}
ch
:=
s
.
Watching
.
ResultChan
()
ch
:=
s
.
Watching
.
ResultChan
()
for
{
for
{
...
@@ -242,10 +243,11 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
...
@@ -242,10 +243,11 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
unknown
.
Raw
=
buf
.
Bytes
()
unknown
.
Raw
=
buf
.
Bytes
()
event
.
Object
=
&
unknown
event
.
Object
=
&
unknown
*
outEvent
=
metav1
.
WatchEvent
{}
// create the external type directly and encode it. Clients will only recognize the serialization we provide.
// create the external type directly and encode it. Clients will only recognize the serialization we provide.
// The internal event is being reused, not reallocated so its just a few extra assignments to do it this way
// The internal event is being reused, not reallocated so its just a few extra assignments to do it this way
// and we get the benefit of using conversion functions which already have to stay in sync
// and we get the benefit of using conversion functions which already have to stay in sync
outEvent
:=
&
metav1
.
WatchEvent
{}
*
internalEvent
=
metav1
.
InternalEvent
(
event
)
*
internalEvent
=
metav1
.
InternalEvent
(
event
)
err
:=
metav1
.
Convert_v1_InternalEvent_To_v1_WatchEvent
(
internalEvent
,
outEvent
,
nil
)
err
:=
metav1
.
Convert_v1_InternalEvent_To_v1_WatchEvent
(
internalEvent
,
outEvent
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment