From 2bbee443210e33536026d7f6760c09a1cff4ef05 Mon Sep 17 00:00:00 2001 From: Christopher Chang Date: Thu, 4 Jul 2024 14:33:00 -0700 Subject: [PATCH] backport nonref_flags elision --- 2.0/plink2_data.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/2.0/plink2_data.cc b/2.0/plink2_data.cc index 2f27d9bb..22b3b548 100644 --- a/2.0/plink2_data.cc +++ b/2.0/plink2_data.cc @@ -6388,6 +6388,16 @@ PglErr MakePgenRobust(const uintptr_t* sample_include, const uint32_t* new_sampl nonref_flags_write = nullptr; nonref_flags_storage = 1; } + } else { + if (nonref_flags_write[0] & 1) { + if (AllBitsAreOne(nonref_flags_write, raw_variant_ct)) { + nonref_flags_write = nullptr; + nonref_flags_storage = 2; + } + } else if (AllWordsAreZero(nonref_flags_write, BitCtToWordCt(raw_variant_ct))) { + nonref_flags_write = nullptr; + nonref_flags_storage = 1; + } } snprintf(outname_end, kMaxOutfnameExtBlen, ".pgen"); uintptr_t spgw_alloc_cacheline_ct; @@ -7517,6 +7527,16 @@ PglErr MakePlink2NoVsort(const uintptr_t* sample_include, const PedigreeIdInfo* nonref_flags_write = nullptr; nonref_flags_storage = 1; } + } else { + if (nonref_flags_write[0] & 1) { + if (AllBitsAreOne(nonref_flags_write, raw_variant_ct)) { + nonref_flags_write = nullptr; + nonref_flags_storage = 2; + } + } else if (AllWordsAreZero(nonref_flags_write, BitCtToWordCt(raw_variant_ct))) { + nonref_flags_write = nullptr; + nonref_flags_storage = 1; + } } ctx.pwcs = &(mpgwp->pwcs[0]); ctx.thread_write_genovecs = nullptr;