Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
9b66768e
Commit
9b66768e
authored
Jun 12, 2015
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimization to avoid foreach over empty lists.
parent
43527448
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
9 deletions
+64
-9
CodedOutputStream.cs
csharp/src/ProtocolBuffers/CodedOutputStream.cs
+64
-9
No files found.
csharp/src/ProtocolBuffers/CodedOutputStream.cs
View file @
9b66768e
...
...
@@ -543,19 +543,14 @@ namespace Google.Protobuf
#
endregion
#
region
Write
array
members
public
void
Write
Group
Array
<
T
>(
int
fieldNumber
,
RepeatedField
<
T
>
list
)
public
void
Write
Message
Array
<
T
>(
int
fieldNumber
,
RepeatedField
<
T
>
list
)
where
T
:
IMessage
{
foreach
(
IMessage
value
in
list
)
if
(
list
.
Count
==
0
)
{
WriteGroup
(
fieldNumber
,
value
)
;
return
;
}
}
public
void
WriteMessageArray
<
T
>(
int
fieldNumber
,
RepeatedField
<
T
>
list
)
where
T
:
IMessage
{
foreach
(
IMessage
value
in
list
)
foreach
(
T
value
in
list
)
{
WriteMessage
(
fieldNumber
,
value
);
}
...
...
@@ -563,6 +558,10 @@ namespace Google.Protobuf
public
void
WriteStringArray
(
int
fieldNumber
,
RepeatedField
<
string
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteString
(
fieldNumber
,
value
);
...
...
@@ -571,6 +570,10 @@ namespace Google.Protobuf
public
void
WriteBytesArray
(
int
fieldNumber
,
RepeatedField
<
ByteString
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteBytes
(
fieldNumber
,
value
);
...
...
@@ -579,6 +582,10 @@ namespace Google.Protobuf
public
void
WriteBoolArray
(
int
fieldNumber
,
RepeatedField
<
bool
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteBool
(
fieldNumber
,
value
);
...
...
@@ -587,6 +594,10 @@ namespace Google.Protobuf
public
void
WriteInt32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteInt32
(
fieldNumber
,
value
);
...
...
@@ -595,6 +606,10 @@ namespace Google.Protobuf
public
void
WriteSInt32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteSInt32
(
fieldNumber
,
value
);
...
...
@@ -603,6 +618,10 @@ namespace Google.Protobuf
public
void
WriteUInt32Array
(
int
fieldNumber
,
RepeatedField
<
uint
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteUInt32
(
fieldNumber
,
value
);
...
...
@@ -611,6 +630,10 @@ namespace Google.Protobuf
public
void
WriteFixed32Array
(
int
fieldNumber
,
RepeatedField
<
uint
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteFixed32
(
fieldNumber
,
value
);
...
...
@@ -619,6 +642,10 @@ namespace Google.Protobuf
public
void
WriteSFixed32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteSFixed32
(
fieldNumber
,
value
);
...
...
@@ -627,6 +654,10 @@ namespace Google.Protobuf
public
void
WriteInt64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteInt64
(
fieldNumber
,
value
);
...
...
@@ -635,6 +666,10 @@ namespace Google.Protobuf
public
void
WriteSInt64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteSInt64
(
fieldNumber
,
value
);
...
...
@@ -643,6 +678,10 @@ namespace Google.Protobuf
public
void
WriteUInt64Array
(
int
fieldNumber
,
RepeatedField
<
ulong
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteUInt64
(
fieldNumber
,
value
);
...
...
@@ -651,6 +690,10 @@ namespace Google.Protobuf
public
void
WriteFixed64Array
(
int
fieldNumber
,
RepeatedField
<
ulong
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteFixed64
(
fieldNumber
,
value
);
...
...
@@ -659,6 +702,10 @@ namespace Google.Protobuf
public
void
WriteSFixed64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteSFixed64
(
fieldNumber
,
value
);
...
...
@@ -667,6 +714,10 @@ namespace Google.Protobuf
public
void
WriteDoubleArray
(
int
fieldNumber
,
RepeatedField
<
double
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteDouble
(
fieldNumber
,
value
);
...
...
@@ -675,6 +726,10 @@ namespace Google.Protobuf
public
void
WriteFloatArray
(
int
fieldNumber
,
RepeatedField
<
float
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteFloat
(
fieldNumber
,
value
);
...
...
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