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
aef072a4
Commit
aef072a4
authored
Jun 08, 2011
by
csharptest
Committed by
rogerk
Jun 08, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed Bytes to ByteArray and added a Reverse method.
parent
4ba365d7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
19 deletions
+33
-19
ByteArray.cs
src/ProtocolBuffers/ByteArray.cs
+17
-3
ByteString.cs
src/ProtocolBuffers/ByteString.cs
+2
-2
CodedInputStream.cs
src/ProtocolBuffers/CodedInputStream.cs
+6
-6
CodedOutputStream.cs
src/ProtocolBuffers/CodedOutputStream.cs
+6
-6
ProtocolBuffers.csproj
src/ProtocolBuffers/ProtocolBuffers.csproj
+1
-1
ProtocolBuffersLite.csproj
src/ProtocolBuffers/ProtocolBuffersLite.csproj
+1
-1
No files found.
src/ProtocolBuffers/Byte
s
.cs
→
src/ProtocolBuffers/Byte
Array
.cs
View file @
aef072a4
...
...
@@ -3,10 +3,10 @@
/// <summary>
/// Provides a utility routine to copy small arrays much more quickly than Buffer.BlockCopy
/// </summary>
static
class
Byte
s
static
class
Byte
Array
{
/// <summary>
/// The threshold above which you should use Buffer.BlockCopy rather than Byte
s
.Copy
/// The threshold above which you should use Buffer.BlockCopy rather than Byte
Array
.Copy
/// </summary>
const
int
CopyThreshold
=
12
;
/// <summary>
...
...
@@ -20,7 +20,7 @@
ByteCopy
(
src
,
srcOffset
,
dst
,
dstOffset
,
count
);
}
/// <summary>
/// Copy
ies
the bytes provided with a for loop, faster when there are only a few bytes to copy
/// Copy the bytes provided with a for loop, faster when there are only a few bytes to copy
/// </summary>
public
static
void
ByteCopy
(
byte
[]
src
,
int
srcOffset
,
byte
[]
dst
,
int
dstOffset
,
int
count
)
{
...
...
@@ -28,5 +28,18 @@
for
(
int
i
=
srcOffset
;
i
<
stop
;
i
++)
dst
[
dstOffset
++]
=
src
[
i
];
}
/// <summary>
/// Reverses the order of bytes in the array
/// </summary>
public
static
void
Reverse
(
byte
[]
bytes
)
{
byte
temp
;
for
(
int
first
=
0
,
last
=
bytes
.
Length
-
1
;
first
<
last
;
first
++,
last
--)
{
temp
=
bytes
[
first
];
bytes
[
first
]
=
bytes
[
last
];
bytes
[
last
]
=
temp
;
}
}
}
}
\ No newline at end of file
src/ProtocolBuffers/ByteString.cs
View file @
aef072a4
...
...
@@ -123,7 +123,7 @@ namespace Google.ProtocolBuffers
public
static
ByteString
CopyFrom
(
byte
[]
bytes
,
int
offset
,
int
count
)
{
byte
[]
portion
=
new
byte
[
count
];
Byte
s
.
Copy
(
bytes
,
offset
,
portion
,
0
,
count
);
Byte
Array
.
Copy
(
bytes
,
offset
,
portion
,
0
,
count
);
return
new
ByteString
(
portion
);
}
...
...
@@ -261,7 +261,7 @@ namespace Google.ProtocolBuffers
/// </summary>
public
void
CopyTo
(
byte
[]
array
,
int
position
)
{
Byte
s
.
Copy
(
bytes
,
0
,
array
,
position
,
bytes
.
Length
);
Byte
Array
.
Copy
(
bytes
,
0
,
array
,
position
,
bytes
.
Length
);
}
/// <summary>
...
...
src/ProtocolBuffers/CodedInputStream.cs
View file @
aef072a4
...
...
@@ -213,7 +213,7 @@ namespace Google.ProtocolBuffers
{
byte
[]
rawBytes
=
ReadRawBytes
(
8
);
if
(!
BitConverter
.
IsLittleEndian
)
Array
.
Reverse
(
rawBytes
);
Byte
Array
.
Reverse
(
rawBytes
);
value
=
BitConverter
.
ToDouble
(
rawBytes
,
0
);
}
#else
...
...
@@ -236,7 +236,7 @@ namespace Google.ProtocolBuffers
{
byte
[]
rawBytes
=
ReadRawBytes
(
4
);
if
(!
BitConverter
.
IsLittleEndian
)
Array
.
Reverse
(
rawBytes
);
Byte
Array
.
Reverse
(
rawBytes
);
value
=
BitConverter
.
ToSingle
(
rawBytes
,
0
);
}
return
true
;
...
...
@@ -1240,7 +1240,7 @@ namespace Google.ProtocolBuffers
{
// We have all the bytes we need already.
byte
[]
bytes
=
new
byte
[
size
];
Byte
s
.
Copy
(
buffer
,
bufferPos
,
bytes
,
0
,
size
);
Byte
Array
.
Copy
(
buffer
,
bufferPos
,
bytes
,
0
,
size
);
bufferPos
+=
size
;
return
bytes
;
}
...
...
@@ -1252,7 +1252,7 @@ namespace Google.ProtocolBuffers
// First copy what we have.
byte
[]
bytes
=
new
byte
[
size
];
int
pos
=
bufferSize
-
bufferPos
;
Byte
s
.
Copy
(
buffer
,
bufferPos
,
bytes
,
0
,
pos
);
Byte
Array
.
Copy
(
buffer
,
bufferPos
,
bytes
,
0
,
pos
);
bufferPos
=
bufferSize
;
// We want to use RefillBuffer() and then copy from the buffer into our
...
...
@@ -1268,7 +1268,7 @@ namespace Google.ProtocolBuffers
RefillBuffer
(
true
);
}
Byte
s
.
Copy
(
buffer
,
0
,
bytes
,
pos
,
size
-
pos
);
Byte
Array
.
Copy
(
buffer
,
0
,
bytes
,
pos
,
size
-
pos
);
bufferPos
=
size
-
pos
;
return
bytes
;
...
...
@@ -1320,7 +1320,7 @@ namespace Google.ProtocolBuffers
// Start by copying the leftover bytes from this.buffer.
int
newPos
=
originalBufferSize
-
originalBufferPos
;
Byte
s
.
Copy
(
buffer
,
originalBufferPos
,
bytes
,
0
,
newPos
);
Byte
Array
.
Copy
(
buffer
,
originalBufferPos
,
bytes
,
0
,
newPos
);
// And now all the chunks.
foreach
(
byte
[]
chunk
in
chunks
)
...
...
src/ProtocolBuffers/CodedOutputStream.cs
View file @
aef072a4
...
...
@@ -648,7 +648,7 @@ namespace Google.ProtocolBuffers
#if SILVERLIGHT2 || COMPACT_FRAMEWORK_35
byte
[]
rawBytes
=
BitConverter
.
GetBytes
(
value
);
if
(!
BitConverter
.
IsLittleEndian
)
Array
.
Reverse
(
rawBytes
);
Byte
Array
.
Reverse
(
rawBytes
);
if
(
limit
-
position
>=
8
)
{
...
...
@@ -674,8 +674,8 @@ namespace Google.ProtocolBuffers
public
void
WriteFloatNoTag
(
float
value
)
{
byte
[]
rawBytes
=
BitConverter
.
GetBytes
(
value
);
if
(!
BitConverter
.
IsLittleEndian
)
Array
.
Reverse
(
rawBytes
);
if
(!
BitConverter
.
IsLittleEndian
)
Byte
Array
.
Reverse
(
rawBytes
);
if
(
limit
-
position
>=
4
)
{
...
...
@@ -1008,7 +1008,7 @@ namespace Google.ProtocolBuffers
{
if
(
limit
-
position
>=
length
)
{
Byte
s
.
Copy
(
value
,
offset
,
buffer
,
position
,
length
);
Byte
Array
.
Copy
(
value
,
offset
,
buffer
,
position
,
length
);
// We have room in the current buffer.
position
+=
length
;
}
...
...
@@ -1017,7 +1017,7 @@ namespace Google.ProtocolBuffers
// Write extends past current buffer. Fill the rest of this buffer and
// flush.
int
bytesWritten
=
limit
-
position
;
Byte
s
.
Copy
(
value
,
offset
,
buffer
,
position
,
bytesWritten
);
Byte
Array
.
Copy
(
value
,
offset
,
buffer
,
position
,
bytesWritten
);
offset
+=
bytesWritten
;
length
-=
bytesWritten
;
position
=
limit
;
...
...
@@ -1029,7 +1029,7 @@ namespace Google.ProtocolBuffers
if
(
length
<=
limit
)
{
// Fits in new buffer.
Byte
s
.
Copy
(
value
,
offset
,
buffer
,
0
,
length
);
Byte
Array
.
Copy
(
value
,
offset
,
buffer
,
0
,
length
);
position
=
length
;
}
else
...
...
src/ProtocolBuffers/ProtocolBuffers.csproj
View file @
aef072a4
...
...
@@ -99,7 +99,7 @@
<Compile
Include=
"AbstractMessageLite.cs"
>
<SubType>
Code
</SubType>
</Compile>
<Compile
Include=
"Byte
s
.cs"
/>
<Compile
Include=
"Byte
Array
.cs"
/>
<Compile
Include=
"ByteString.cs"
/>
<Compile
Include=
"Collections\Enumerables.cs"
/>
<Compile
Include=
"Collections\IPopsicleList.cs"
/>
...
...
src/ProtocolBuffers/ProtocolBuffersLite.csproj
View file @
aef072a4
...
...
@@ -78,7 +78,7 @@
<ItemGroup>
<Compile
Include=
"AbstractBuilderLite.cs"
/>
<Compile
Include=
"AbstractMessageLite.cs"
/>
<Compile
Include=
"Byte
s
.cs"
/>
<Compile
Include=
"Byte
Array
.cs"
/>
<Compile
Include=
"CodedOutputStream.ComputeSize.cs"
/>
<Compile
Include=
"Collections\Dictionaries.cs"
/>
<Compile
Include=
"Collections\Enumerables.cs"
/>
...
...
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