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
a0f95693
Commit
a0f95693
authored
Jun 17, 2015
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use our "local" copy of Encoding.UTF8 in CodedInputStream too.
parent
a09b4910
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
CodedInputStream.cs
csharp/src/ProtocolBuffers/CodedInputStream.cs
+2
-2
CodedOutputStream.ComputeSize.cs
csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
+1
-1
CodedOutputStream.cs
csharp/src/ProtocolBuffers/CodedOutputStream.cs
+5
-4
No files found.
csharp/src/ProtocolBuffers/CodedInputStream.cs
View file @
a0f95693
...
...
@@ -339,12 +339,12 @@ namespace Google.Protobuf
{
// Fast path: We already have the bytes in a contiguous buffer, so
// just copy directly from it.
String
result
=
Encoding
.
UTF8
.
GetString
(
buffer
,
bufferPos
,
size
);
String
result
=
CodedOutputStream
.
Utf8Encoding
.
GetString
(
buffer
,
bufferPos
,
size
);
bufferPos
+=
size
;
return
result
;
}
// Slow path: Build a byte array first then copy it.
return
Encoding
.
UTF8
.
GetString
(
ReadRawBytes
(
size
),
0
,
size
);
return
CodedOutputStream
.
Utf8Encoding
.
GetString
(
ReadRawBytes
(
size
),
0
,
size
);
}
/// <summary>
...
...
csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
View file @
a0f95693
...
...
@@ -135,7 +135,7 @@ namespace Google.Protobuf
/// </summary>
public
static
int
ComputeStringSize
(
String
value
)
{
int
byteArraySize
=
U
TF8
.
GetByteCount
(
value
);
int
byteArraySize
=
U
tf8Encoding
.
GetByteCount
(
value
);
return
ComputeRawVarint32Size
((
uint
)
byteArraySize
)
+
byteArraySize
;
}
...
...
csharp/src/ProtocolBuffers/CodedOutputStream.cs
View file @
a0f95693
...
...
@@ -59,7 +59,8 @@ namespace Google.Protobuf
/// </remarks>
public
sealed
partial
class
CodedOutputStream
{
private
static
readonly
Encoding
UTF8
=
Encoding
.
UTF8
;
// "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.)
internal
static
readonly
Encoding
Utf8Encoding
=
Encoding
.
UTF8
;
/// <summary>
/// The buffer size used by CreateInstance(Stream).
...
...
@@ -240,7 +241,7 @@ namespace Google.Protobuf
{
// Optimise the case where we have enough space to write
// the string directly to the buffer, which should be common.
int
length
=
U
TF8
.
GetByteCount
(
value
);
int
length
=
U
tf8Encoding
.
GetByteCount
(
value
);
WriteRawVarint32
((
uint
)
length
);
if
(
limit
-
position
>=
length
)
{
...
...
@@ -253,13 +254,13 @@ namespace Google.Protobuf
}
else
{
U
TF8
.
GetBytes
(
value
,
0
,
value
.
Length
,
buffer
,
position
);
U
tf8Encoding
.
GetBytes
(
value
,
0
,
value
.
Length
,
buffer
,
position
);
}
position
+=
length
;
}
else
{
byte
[]
bytes
=
U
TF8
.
GetBytes
(
value
);
byte
[]
bytes
=
U
tf8Encoding
.
GetBytes
(
value
);
WriteRawBytes
(
bytes
);
}
}
...
...
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