@@ -390,7 +390,7 @@ class CBLSLazyWrapper
390
390
private:
391
391
mutable std::mutex mutex;
392
392
393
- mutable std::array<uint8_t , BLSObject::SerSize> vecBytes;
393
+ mutable std::array<uint8_t , BLSObject::SerSize> vecBytes{} ;
394
394
395
395
mutable BLSObject obj;
396
396
mutable bool objInitialized{false };
@@ -403,7 +403,6 @@ class CBLSLazyWrapper
403
403
404
404
public:
405
405
CBLSLazyWrapper () :
406
- vecBytes{},
407
406
bufLegacyScheme (bls::bls_legacy_scheme.load())
408
407
{}
409
408
@@ -418,16 +417,10 @@ class CBLSLazyWrapper
418
417
std::unique_lock<std::mutex> l (r.mutex );
419
418
bufValid = r.bufValid ;
420
419
bufLegacyScheme = r.bufLegacyScheme ;
421
- if (r.bufValid ) {
422
- vecBytes = r.vecBytes ;
423
- } else {
424
- std::fill (vecBytes.begin (), vecBytes.end (), 0 );
425
- }
420
+ vecBytes = r.vecBytes ;
426
421
objInitialized = r.objInitialized ;
427
422
if (r.objInitialized ) {
428
423
obj = r.obj ;
429
- } else {
430
- obj.Reset ();
431
424
}
432
425
hash = r.hash ;
433
426
return *this ;
@@ -442,13 +435,18 @@ class CBLSLazyWrapper
442
435
inline void Serialize (Stream& s, const bool specificLegacyScheme) const
443
436
{
444
437
std::unique_lock<std::mutex> l (mutex);
445
- if (!objInitialized && !bufValid) {
446
- std::fill (vecBytes.begin (), vecBytes.end (), 0 );
447
- } else if (!bufValid || (bufLegacyScheme != specificLegacyScheme)) {
448
- vecBytes = obj.ToBytes (specificLegacyScheme);
449
- bufValid = true ;
450
- bufLegacyScheme = specificLegacyScheme;
451
- hash.SetNull ();
438
+ if (!objInitialized) {
439
+ if (bufValid && bufLegacyScheme != specificLegacyScheme) {
440
+ obj.SetBytes (vecBytes, bufLegacyScheme);
441
+ vecBytes = obj.ToBytes (specificLegacyScheme);
442
+ }
443
+ } else {
444
+ if (!bufValid || (bufLegacyScheme != specificLegacyScheme)) {
445
+ vecBytes = obj.ToBytes (specificLegacyScheme);
446
+ bufValid = true ;
447
+ bufLegacyScheme = specificLegacyScheme;
448
+ hash.SetNull ();
449
+ }
452
450
}
453
451
s.write (MakeByteSpan (vecBytes));
454
452
}
@@ -483,6 +481,7 @@ class CBLSLazyWrapper
483
481
bufLegacyScheme = specificLegacyScheme;
484
482
objInitialized = true ;
485
483
obj = _obj;
484
+ std::fill (vecBytes.begin (), vecBytes.end (), 0 );
486
485
hash.SetNull ();
487
486
}
488
487
const BLSObject& Get () const
@@ -539,7 +538,6 @@ class CBLSLazyWrapper
539
538
{
540
539
std::unique_lock<std::mutex> l (mutex);
541
540
if (!objInitialized && !bufValid) {
542
- std::fill (vecBytes.begin (), vecBytes.end (), 0 );
543
541
hash.SetNull ();
544
542
} else if (!bufValid) {
545
543
vecBytes = obj.ToBytes (bufLegacyScheme);
0 commit comments