@@ -25,6 +25,13 @@ function __construct($h, $l)
2525 $ this ->lo = $ l ; // >>> 0;
2626 }
2727
28+ function setHiLo ($ h , $ l )
29+ {
30+ $ this ->hi = $ h ; // >>> 0;
31+ $ this ->lo = $ l ; // >>> 0;
32+ return $ this ;
33+ }
34+
2835 function set (UnsignedInt64 $ oWord )
2936 {
3037 throw new Exception ('No plz ' );
@@ -92,13 +99,13 @@ function not()
9299 function one ()
93100 {
94101 // throw new Exception('No plz');
95- return new UnsignedInt64 (0x0 , 0x1 );
102+ return UInt64Pool:: getObject ()-> setHiLo (0x0 , 0x1 );
96103 }
97104
98105 function zero ()
99106 {
100107 //throw new Exception('No plz');
101- return new UnsignedInt64 (0x0 , 0x0 );
108+ return UInt64Pool:: getObject ()-> setHiLo (0x0 , 0x0 );
102109 }
103110
104111 function neg ()
@@ -178,15 +185,15 @@ function multiply(UnsignedInt64 $multiplier)
178185
179186 $ c48 += $ a48 * $ b00 + $ a32 * $ b16 + $ a16 * $ b32 + $ a00 * $ b48 ;
180187 $ c48 &= 0xFFFF ;
181- return new UnsignedInt64 ((($ c48 << 16 ) | $ c32 ) & 0xffffffff , (($ c16 << 16 ) | $ c00 ) & 0xffffffff );
188+ return UInt64Pool:: getObject ()-> setHiLo ((($ c48 << 16 ) | $ c32 ) & 0xffffffff , (($ c16 << 16 ) | $ c00 ) & 0xffffffff );
182189 }
183190
184191 function shiftLeft ($ bits )
185192 {
186193 $ this_h = $ this ->hi & 0xffffffff ;
187194 $ this_l = $ this ->lo & 0xffffffff ;
188195 $ bits %= 64 ;
189- $ c = new UnsignedInt64 (0 , 0 );
196+ $ c = UInt64Pool:: getObject ()-> setHiLo (0 , 0 );
190197 if ($ bits === 0 )
191198 {
192199 return clone $ this ;
@@ -239,7 +246,7 @@ function shiftRight($bits)
239246 $ this_h = $ this ->hi & 0xffffffff ;
240247 $ this_l = $ this ->lo & 0xffffffff ;
241248 $ nmaxBits = PHP_INT_SIZE * 8 ;
242- $ c = new UnsignedInt64 (0 , 0 );
249+ $ c = UInt64Pool:: getObject ()-> setHiLo (0 , 0 );
243250 if ($ bits >= 32 )
244251 {//больше 32
245252 $ c ->hi = -1 ;
@@ -259,7 +266,7 @@ function shiftRightUnsigned($bits)
259266 $ bits %= 64 ;
260267 if ($ bits === 0 )
261268 return clone $ this ;
262- $ c = new UnsignedInt64 (0 , 0 );
269+ $ c = UInt64Pool:: getObject ()-> setHiLo (0 , 0 );
263270 $ this_h = $ this ->hi & 0xffffffff ;
264271 $ this_l = $ this ->lo & 0xffffffff ;
265272 if ($ bits >= 32 )
@@ -285,7 +292,7 @@ function rotateLeft($bits)
285292 {
286293 return $ this ->rotateRight (64 - $ bits );
287294 }
288- $ c = new UnsignedInt64 (0 , 0 );
295+ $ c = UInt64Pool:: getObject ()-> setHiLo (0 , 0 );
289296 if ($ bits === 0 )
290297 {
291298 $ c ->lo = $ this ->lo >> 0 ;
@@ -419,7 +426,7 @@ function __xor(UnsignedInt64 $oWord)
419426 $ this_l = $ this ->lo & 0xffffffff ;
420427 $ o_h = $ oWord ->hi & 0xffffffff ;
421428 $ o_l = $ oWord ->lo & 0xffffffff ;
422- $ c = new UnsignedInt64 (0 , 0 );
429+ $ c = UInt64Pool:: getObject ()-> setHiLo (0 , 0 );
423430 $ c ->hi = $ this_h ^ $ o_h ;
424431 $ c ->lo = $ this_l ^ $ o_l ;
425432 return $ c ; //for chaining..
@@ -440,15 +447,15 @@ function setxorOne(UnsignedInt64 $oWord)
440447//Ands this word with the given other..
441448 function __and (UnsignedInt64 $ oWord )
442449 {
443- $ c = new UnsignedInt64 (0 , 0 );
450+ $ c = UInt64Pool:: getObject ()-> setHiLo (0 , 0 );
444451 $ c ->hi = $ this ->hi & $ oWord ->hi ;
445452 $ c ->lo = $ this ->lo & $ oWord ->lo ;
446453 return $ c ; //for chaining..
447454 }
448455
449456 function __or (UnsignedInt64 $ oWord )
450457 {
451- $ c = new UnsignedInt64 (0 , 0 );
458+ $ c = UInt64Pool:: getObject ()-> setHiLo (0 , 0 );
452459 $ c ->hi = $ this ->hi | $ oWord ->hi ;
453460 $ c ->lo = $ this ->lo | $ oWord ->lo ;
454461 return $ c ; //for chaining..
@@ -457,7 +464,7 @@ function __or(UnsignedInt64 $oWord)
457464//Creates a deep copy of this Word..
458465 function __clone ()
459466 {
460- return new UnsignedInt64 ($ this ->hi , $ this ->lo );
467+ return UInt64Pool:: getObject ()-> setHiLo ($ this ->hi , $ this ->lo );
461468 }
462469
463470 function setxor64 ()
@@ -488,7 +495,7 @@ function __toString()
488495
489496function o_u ($ h , $ l )
490497{
491- return new UnsignedInt64 ($ h , $ l );
498+ return UInt64Pool:: getObject ()-> setHiLo ($ h , $ l );
492499}
493500
494501function xor64 ()
@@ -504,7 +511,7 @@ function xor64()
504511 $ i --;
505512 }
506513 while ($ i > 0 );
507- return new UnsignedInt64 ($ h , $ l );
514+ return UInt64Pool:: getObject ()-> setHiLo ($ h , $ l );
508515}
509516
510517function clone64Array (array $ arr )
@@ -560,7 +567,7 @@ function swap32Array(array $a)
560567
561568function xnd64 ($ x , $ y , $ z )
562569{
563- return new UnsignedInt64 ($ x ->hi ^ ((~$ y ->hi ) & $ z ->hi ), $ x ->lo ^ ((~$ y ->lo ) & $ z ->lo ));
570+ return UInt64Pool:: getObject ()-> setHiLo ($ x ->hi ^ ((~$ y ->hi ) & $ z ->hi ), $ x ->lo ^ ((~$ y ->lo ) & $ z ->lo ));
564571}
565572
566573/*
@@ -709,21 +716,21 @@ function bufferEncode64_(&$buffer, $offset, $uint64)
709716
710717function b2int64 ($ b )
711718{
712- return new UnsignedInt64 (
719+ return UInt64Pool:: getObject ()-> setHiLo (
713720 ($ b [0 ] << 24 ) | ($ b [1 ] << 16 ) | ($ b [2 ] << 8 ) | $ b [3 ] << 0
714721 , ($ b [4 ] << 24 ) | ($ b [5 ] << 16 ) | ($ b [6 ] << 8 ) | $ b [7 ] << 0 );
715722}
716723
717724function b2int64_B ($ b )
718725{
719- return new UnsignedInt64 (
726+ return UInt64Pool:: getObject ()-> setHiLo (
720727 ($ b [4 ] << 24 ) | ($ b [5 ] << 16 ) | ($ b [6 ] << 8 ) | ($ b [7 ] << 0 )
721728 , ($ b [0 ] << 24 ) | ($ b [1 ] << 16 ) | ($ b [2 ] << 8 ) | ($ b [3 ] << 0 ));
722729}
723730
724731function b2int64_ ($ b )
725732{
726- return new UnsignedInt64 (
733+ return UInt64Pool:: getObject ()-> setHiLo (
727734 ($ b [0 ] << 0 ) | ($ b [1 ] << 8 ) | ($ b [2 ] << 16 ) | $ b [3 ] << 24
728735 , ($ b [4 ] << 0 ) | ($ b [5 ] << 8 ) | ($ b [6 ] << 16 ) | $ b [7 ] << 24 );
729736}
@@ -743,7 +750,7 @@ function bytes2Int64Buffer($b)
743750 $ j = 0 ;
744751 while ($ j < $ len )
745752 {
746- $ buffer [$ j ] = new UnsignedInt64 (
753+ $ buffer [$ j ] = UInt64Pool:: getObject ()-> setHiLo (
747754 ($ b [$ j * 8 ] << 24 ) | ($ b [$ j * 8 + 1 ] << 16 ) | ($ b [$ j * 8 + 2 ] << 8 ) | $ b [$ j * 8 + 3 ]
748755 , ($ b [$ j * 8 + 4 ] << 24 ) | ($ b [$ j * 8 + 5 ] << 16 ) | ($ b [$ j * 8 + 6 ] << 8 ) | $ b [$ j * 8 + 7 ]);
749756 $ j ++;
0 commit comments