1515
1616#include < cinttypes>
1717#include < cmath>
18- #include < typeinfo>
1918
2019#include < faiss/impl/FaissAssert.h>
2120#include < faiss/utils/random.h>
@@ -313,9 +312,6 @@ bool ParameterSpace::combination_ge(size_t c1, size_t c2) const {
313312 return true ;
314313}
315314
316- #define DC (classname ) \
317- [[maybe_unused]] const classname* ix = dynamic_cast <const classname*>(index)
318-
319315static void init_pq_ParameterRange (
320316 const ProductQuantizer& pq,
321317 ParameterRange& pr) {
@@ -339,6 +335,10 @@ ParameterRange& ParameterSpace::add_range(const std::string& name) {
339335 return parameter_ranges.back ();
340336}
341337
338+ // Do not use this macro if ix will be unused
339+ #define DC (classname ) \
340+ const classname* ix = dynamic_cast <const classname*>(index)
341+
342342// / initialize with reasonable parameters for this type of index
343343void ParameterSpace::initialize (const Index* index) {
344344 if (DC (IndexPreTransform)) {
@@ -394,7 +394,7 @@ void ParameterSpace::initialize(const Index* index) {
394394 std::numeric_limits<double >::infinity ());
395395 }
396396 }
397- if (DC ( IndexIVFPQR)) {
397+ if (dynamic_cast < const IndexIVFPQR*>(index )) {
398398 ParameterRange& pr = add_range (" k_factor" );
399399 for (int i = 0 ; i <= 6 ; i++) {
400400 pr.values .push_back (1 << i);
@@ -410,9 +410,6 @@ void ParameterSpace::initialize(const Index* index) {
410410
411411#undef DC
412412
413- // non-const version
414- #define DC (classname ) classname* ix = dynamic_cast <classname*>(index)
415-
416413// / set a combination of parameters on an index
417414void ParameterSpace::set_index_parameters (Index* index, size_t cno) const {
418415 for (int i = 0 ; i < parameter_ranges.size (); i++) {
@@ -442,6 +439,10 @@ void ParameterSpace::set_index_parameters(
442439 }
443440}
444441
442+ // non-const version
443+ // Do not use this macro if ix will be unused
444+ #define DC (classname ) classname* ix = dynamic_cast <classname*>(index)
445+
445446void ParameterSpace::set_index_parameter (
446447 Index* index,
447448 const std::string& name,
@@ -574,6 +575,8 @@ void ParameterSpace::set_index_parameter(
574575 name.c_str ());
575576}
576577
578+ #undef DC
579+
577580void ParameterSpace::display () const {
578581 printf (" ParameterSpace, %zd parameters, %zd combinations:\n " ,
579582 parameter_ranges.size (),
0 commit comments