Commit 437e013
abacus_fixer
refactor(hsolver_test): replace unique_ptr heap alloc with stack vars in bpcg test
The alpha/beta scaling constants passed to ModuleBase::gemm_op inside
hpsi_func were heap-allocated via std::unique_ptr<T>(new T(...)) and
then re-exposed through .get(). GEMM only reads these values (const T*
alpha / const T* beta in gemm_op::operator()), so heap allocation is
unnecessary — the lambda performs a fresh new/delete pair on every call
for no semantic benefit.
Replace with stack-local const T one(1.0) / const T zero(0.0) and pass
&one / &zero directly. The result is fully C++11-compatible (indeed
C++98-compatible), shorter, and removes the only std::unique_ptr use in
the file, so <memory> is no longer needed even indirectly through this
translation unit's own code.
Verified by building the MODULE_HSOLVER_bpcg test target:
make -j 30 MODULE_HSOLVER_bpcg
-> [100%] Built target MODULE_HSOLVER_bpcg1 parent e1394a6 commit 437e013
1 file changed
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 139 | + | |
| 140 | + | |
143 | 141 | | |
144 | 142 | | |
145 | 143 | | |
146 | 144 | | |
147 | 145 | | |
148 | 146 | | |
149 | | - | |
| 147 | + | |
150 | 148 | | |
151 | 149 | | |
152 | | - | |
| 150 | + | |
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
| |||
0 commit comments