@@ -323,16 +323,13 @@ public short getShort()
323
323
return v ;
324
324
}
325
325
326
- unsafe
327
326
public short getShort ( int pos )
328
327
{
329
328
checkUnderflow ( pos , 2 ) ;
330
329
if ( NO . _o == _order )
331
330
{
332
- fixed( byte * p = & _bytes [ pos ] )
333
- {
334
- _valBytes . shortVal = * ( ( short * ) p ) ;
335
- }
331
+ _valBytes . b0 = _bytes [ pos ] ;
332
+ _valBytes . b1 = _bytes [ pos + 1 ] ;
336
333
}
337
334
else
338
335
{
@@ -363,17 +360,14 @@ public void getShortSeq(short[] seq)
363
360
_position += len ;
364
361
}
365
362
366
- unsafe
367
363
public ByteBuffer putShort ( short val )
368
364
{
369
365
checkOverflow ( 2 ) ;
370
366
_valBytes . shortVal = val ;
371
367
if ( NO . _o == _order )
372
368
{
373
- fixed( byte * p = & _bytes [ _position ] )
374
- {
375
- * ( ( short * ) p ) = _valBytes. shortVal ;
376
- }
369
+ _bytes [ _position ] = _valBytes . b0 ;
370
+ _bytes [ _position + 1 ] = _valBytes . b1 ;
377
371
}
378
372
else
379
373
{
@@ -406,16 +400,15 @@ public ByteBuffer putShortSeq(short[] seq)
406
400
return this ;
407
401
}
408
402
409
- unsafe
410
403
public int getInt ( )
411
404
{
412
405
checkUnderflow ( 4 ) ;
413
406
if ( NO . _o == _order )
414
407
{
415
- fixed ( byte * p = & _bytes [ _position ] )
416
- {
417
- _valBytes . intVal = * ( ( int * ) p ) ;
418
- }
408
+ _valBytes . b0 = _bytes [ _position ] ;
409
+ _valBytes . b1 = _bytes [ _position + 1 ] ;
410
+ _valBytes . b2 = _bytes [ _position + 2 ] ;
411
+ _valBytes . b3 = _bytes [ _position + 3 ] ;
419
412
}
420
413
else
421
414
{
@@ -458,7 +451,6 @@ public ByteBuffer putInt(int val)
458
451
return this ;
459
452
}
460
453
461
- unsafe
462
454
public ByteBuffer putInt ( int pos , int val )
463
455
{
464
456
if ( pos < 0 )
@@ -472,10 +464,10 @@ public ByteBuffer putInt(int pos, int val)
472
464
_valBytes . intVal = val ;
473
465
if ( NO . _o == _order )
474
466
{
475
- fixed ( byte * p = & _bytes [ pos ] )
476
- {
477
- * ( ( int * ) p ) = _valBytes. intVal ;
478
- }
467
+ _bytes [ pos ] = _valBytes . b0 ;
468
+ _bytes [ pos + 1 ] = _valBytes . b1 ;
469
+ _bytes [ pos + 2 ] = _valBytes . b2 ;
470
+ _bytes [ pos + 3 ] = _valBytes . b3 ;
479
471
}
480
472
else
481
473
{
@@ -518,16 +510,19 @@ public long getLong()
518
510
return v ;
519
511
}
520
512
521
- unsafe
522
513
public long getLong ( int pos )
523
514
{
524
515
checkUnderflow ( pos , 8 ) ;
525
516
if ( NO . _o == _order )
526
517
{
527
- fixed( byte * p = & _bytes [ pos ] )
528
- {
529
- _valBytes . longVal = * ( ( long * ) p ) ;
530
- }
518
+ _valBytes . b0 = _bytes [ pos ] ;
519
+ _valBytes . b1 = _bytes [ pos + 1 ] ;
520
+ _valBytes . b2 = _bytes [ pos + 2 ] ;
521
+ _valBytes . b3 = _bytes [ pos + 3 ] ;
522
+ _valBytes . b4 = _bytes [ pos + 4 ] ;
523
+ _valBytes . b5 = _bytes [ pos + 5 ] ;
524
+ _valBytes . b6 = _bytes [ pos + 6 ] ;
525
+ _valBytes . b7 = _bytes [ pos + 7 ] ;
531
526
}
532
527
else
533
528
{
@@ -570,17 +565,20 @@ public void getLongSeq(long[] seq)
570
565
_position += len ;
571
566
}
572
567
573
- unsafe
574
568
public ByteBuffer putLong ( long val )
575
569
{
576
570
checkOverflow ( 8 ) ;
577
571
_valBytes . longVal = val ;
578
572
if ( NO . _o == _order )
579
573
{
580
- fixed( byte * p = & _bytes [ _position ] )
581
- {
582
- * ( ( long * ) p ) = _valBytes. longVal ;
583
- }
574
+ _bytes [ _position ] = _valBytes . b0 ;
575
+ _bytes [ _position + 1 ] = _valBytes . b1 ;
576
+ _bytes [ _position + 2 ] = _valBytes . b2 ;
577
+ _bytes [ _position + 3 ] = _valBytes . b3 ;
578
+ _bytes [ _position + 4 ] = _valBytes . b4 ;
579
+ _bytes [ _position + 5 ] = _valBytes . b5 ;
580
+ _bytes [ _position + 6 ] = _valBytes . b6 ;
581
+ _bytes [ _position + 7 ] = _valBytes . b7 ;
584
582
}
585
583
else
586
584
{
@@ -625,16 +623,15 @@ public ByteBuffer putLongSeq(long[] seq)
625
623
return this ;
626
624
}
627
625
628
- unsafe
629
626
public float getFloat ( )
630
627
{
631
628
checkUnderflow ( 4 ) ;
632
629
if ( NO . _o == _order )
633
630
{
634
- fixed ( byte * p = & _bytes [ _position ] )
635
- {
636
- _valBytes . floatVal = * ( ( float * ) p ) ;
637
- }
631
+ _valBytes . b0 = _bytes [ _position ] ;
632
+ _valBytes . b1 = _bytes [ _position + 1 ] ;
633
+ _valBytes . b2 = _bytes [ _position + 2 ] ;
634
+ _valBytes . b3 = _bytes [ _position + 3 ] ;
638
635
}
639
636
else
640
637
{
@@ -670,17 +667,16 @@ public void getFloatSeq(float[] seq)
670
667
_position += len ;
671
668
}
672
669
673
- unsafe
674
670
public ByteBuffer putFloat ( float val )
675
671
{
676
672
checkOverflow ( 4 ) ;
677
673
_valBytes . floatVal = val ;
678
674
if ( NO . _o == _order )
679
675
{
680
- fixed ( byte * p = & _bytes [ _position ] )
681
- {
682
- * ( ( float * ) p ) = _valBytes. floatVal ;
683
- }
676
+ _bytes [ _position ] = _valBytes . b0 ;
677
+ _bytes [ _position + 1 ] = _valBytes . b1 ;
678
+ _bytes [ _position + 2 ] = _valBytes . b2 ;
679
+ _bytes [ _position + 3 ] = _valBytes . b3 ;
684
680
}
685
681
else
686
682
{
@@ -717,16 +713,19 @@ public ByteBuffer putFloatSeq(float[] seq)
717
713
return this ;
718
714
}
719
715
720
- unsafe
721
716
public double getDouble ( )
722
717
{
723
718
checkUnderflow ( 8 ) ;
724
719
if ( NO . _o == _order )
725
720
{
726
- fixed( byte * p = & _bytes [ _position ] )
727
- {
728
- _valBytes . doubleVal = * ( ( double * ) p ) ;
729
- }
721
+ _valBytes . b0 = _bytes [ _position ] ;
722
+ _valBytes . b1 = _bytes [ _position + 1 ] ;
723
+ _valBytes . b2 = _bytes [ _position + 2 ] ;
724
+ _valBytes . b3 = _bytes [ _position + 3 ] ;
725
+ _valBytes . b4 = _bytes [ _position + 4 ] ;
726
+ _valBytes . b5 = _bytes [ _position + 5 ] ;
727
+ _valBytes . b6 = _bytes [ _position + 6 ] ;
728
+ _valBytes . b7 = _bytes [ _position + 7 ] ;
730
729
}
731
730
else
732
731
{
@@ -770,17 +769,20 @@ public void getDoubleSeq(double[] seq)
770
769
_position += len ;
771
770
}
772
771
773
- unsafe
774
772
public ByteBuffer putDouble ( double val )
775
773
{
776
774
checkOverflow ( 8 ) ;
777
775
_valBytes . doubleVal = val ;
778
776
if ( NO . _o == _order )
779
777
{
780
- fixed( byte * p = & _bytes [ _position ] )
781
- {
782
- * ( ( double * ) p ) = _valBytes. doubleVal ;
783
- }
778
+ _bytes [ _position ] = _valBytes . b0 ;
779
+ _bytes [ _position + 1 ] = _valBytes . b1 ;
780
+ _bytes [ _position + 2 ] = _valBytes . b2 ;
781
+ _bytes [ _position + 3 ] = _valBytes . b3 ;
782
+ _bytes [ _position + 4 ] = _valBytes . b4 ;
783
+ _bytes [ _position + 5 ] = _valBytes . b5 ;
784
+ _bytes [ _position + 6 ] = _valBytes . b6 ;
785
+ _bytes [ _position + 7 ] = _valBytes . b7 ;
784
786
}
785
787
else
786
788
{
0 commit comments