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
3f9be70d
Commit
3f9be70d
authored
Jun 06, 2015
by
Feng Xiao
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #361 from brianduff/sync_aosp
Speed up little endian int/long writes.
parents
b9baa47e
695715ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
CodedOutputByteBufferNano.java
...a/com/google/protobuf/nano/CodedOutputByteBufferNano.java
+10
-12
No files found.
javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java
View file @
3f9be70d
...
@@ -33,6 +33,7 @@ package com.google.protobuf.nano;
...
@@ -33,6 +33,7 @@ package com.google.protobuf.nano;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.BufferOverflowException
;
import
java.nio.BufferOverflowException
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteOrder
;
import
java.nio.ReadOnlyBufferException
;
import
java.nio.ReadOnlyBufferException
;
/**
/**
...
@@ -61,6 +62,7 @@ public final class CodedOutputByteBufferNano {
...
@@ -61,6 +62,7 @@ public final class CodedOutputByteBufferNano {
private
CodedOutputByteBufferNano
(
final
ByteBuffer
buffer
)
{
private
CodedOutputByteBufferNano
(
final
ByteBuffer
buffer
)
{
this
.
buffer
=
buffer
;
this
.
buffer
=
buffer
;
this
.
buffer
.
order
(
ByteOrder
.
LITTLE_ENDIAN
);
}
}
/**
/**
...
@@ -1038,24 +1040,20 @@ public final class CodedOutputByteBufferNano {
...
@@ -1038,24 +1040,20 @@ public final class CodedOutputByteBufferNano {
/** Write a little-endian 32-bit integer. */
/** Write a little-endian 32-bit integer. */
public
void
writeRawLittleEndian32
(
final
int
value
)
throws
IOException
{
public
void
writeRawLittleEndian32
(
final
int
value
)
throws
IOException
{
writeRawByte
((
value
)
&
0xFF
);
if
(
buffer
.
remaining
()
<
4
)
{
writeRawByte
((
value
>>
8
)
&
0xFF
);
throw
new
OutOfSpaceException
(
buffer
.
position
(),
buffer
.
limit
()
);
writeRawByte
((
value
>>
16
)
&
0xFF
);
}
writeRawByte
((
value
>>
24
)
&
0xFF
);
buffer
.
putInt
(
value
);
}
}
public
static
final
int
LITTLE_ENDIAN_32_SIZE
=
4
;
public
static
final
int
LITTLE_ENDIAN_32_SIZE
=
4
;
/** Write a little-endian 64-bit integer. */
/** Write a little-endian 64-bit integer. */
public
void
writeRawLittleEndian64
(
final
long
value
)
throws
IOException
{
public
void
writeRawLittleEndian64
(
final
long
value
)
throws
IOException
{
writeRawByte
((
int
)(
value
)
&
0xFF
);
if
(
buffer
.
remaining
()
<
8
)
{
writeRawByte
((
int
)(
value
>>
8
)
&
0xFF
);
throw
new
OutOfSpaceException
(
buffer
.
position
(),
buffer
.
limit
());
writeRawByte
((
int
)(
value
>>
16
)
&
0xFF
);
}
writeRawByte
((
int
)(
value
>>
24
)
&
0xFF
);
buffer
.
putLong
(
value
);
writeRawByte
((
int
)(
value
>>
32
)
&
0xFF
);
writeRawByte
((
int
)(
value
>>
40
)
&
0xFF
);
writeRawByte
((
int
)(
value
>>
48
)
&
0xFF
);
writeRawByte
((
int
)(
value
>>
56
)
&
0xFF
);
}
}
public
static
final
int
LITTLE_ENDIAN_64_SIZE
=
8
;
public
static
final
int
LITTLE_ENDIAN_64_SIZE
=
8
;
...
...
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