File tree Expand file tree Collapse file tree 3 files changed +3
-24
lines changed Expand file tree Collapse file tree 3 files changed +3
-24
lines changed Original file line number Diff line number Diff line change @@ -192,11 +192,7 @@ public void writeObjectId(final ObjectId objectId) {
192
192
buffer .write (BsonType .OBJECT_ID .getValue ());
193
193
writeCurrentName ();
194
194
195
- // TODO: Should this be pushed down into the buffer?
196
- buffer .writeIntBE (objectId .time ());
197
- buffer .writeIntBE (objectId .machine ());
198
- buffer .writeIntBE (objectId .inc ());
199
-
195
+ buffer .write (objectId .toByteArray ());
200
196
setState (getNextState ());
201
197
}
202
198
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ public String readString() {
80
80
81
81
@ Override
82
82
public ObjectId readObjectId () {
83
- return new ObjectId (readBigEndianInt (), readBigEndianInt (), readBigEndianInt ( ));
83
+ return new ObjectId (readBytes ( 12 ));
84
84
}
85
85
86
86
@ Override
@@ -97,12 +97,11 @@ public String readCString() {
97
97
buffer .position (mark );
98
98
99
99
final byte [] bytes = readBytes (size );
100
- readByte (); // read the trailing null bytes
100
+ readByte (); // read the trailing null byte
101
101
102
102
return new String (bytes , UTF8_CHARSET );
103
103
}
104
104
105
-
106
105
private void readUntilNullByte () {
107
106
//CHECKSTYLE:OFF
108
107
while (buffer .get () != 0 ) {
@@ -120,13 +119,4 @@ public void skipCString() {
120
119
public void skip (final int numBytes ) {
121
120
buffer .position (buffer .position () + numBytes );
122
121
}
123
-
124
- private int readBigEndianInt () {
125
- int x = 0 ;
126
- x |= (0xFF & buffer .get ()) << 24 ;
127
- x |= (0xFF & buffer .get ()) << 16 ;
128
- x |= (0xFF & buffer .get ()) << 8 ;
129
- x |= (0xFF & buffer .get ());
130
- return x ;
131
- }
132
122
}
Original file line number Diff line number Diff line change @@ -77,13 +77,6 @@ public void writeInt(final int x) {
77
77
write (x >> 24 );
78
78
}
79
79
80
- public void writeIntBE (final int x ) {
81
- write (x >> 24 );
82
- write (x >> 16 );
83
- write (x >> 8 );
84
- write (x );
85
- }
86
-
87
80
/**
88
81
* Backpatches the size of a document or string by writing the size into the four bytes starting at getPosition() -
89
82
* size.
You can’t perform that action at this time.
0 commit comments