gen, bitset: use clz() to simplify
Fixes #448. * spot/gen/automata.cc (ulog2): Here. * spot/misc/bitset.hh: And there.
This commit is contained in:
parent
d1cc45f223
commit
8e8f77756d
2 changed files with 7 additions and 25 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2017-2019 Laboratoire de Recherche et Developpement
|
// Copyright (C) 2017-2019, 2021 Laboratoire de Recherche et
|
||||||
// de l'EPITA (LRDE).
|
// Developpement de l'EPITA (LRDE).
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
//
|
//
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include <spot/twa/twagraph.hh>
|
#include <spot/twa/twagraph.hh>
|
||||||
#include <spot/gen/automata.hh>
|
#include <spot/gen/automata.hh>
|
||||||
#include <spot/tl/parse.hh>
|
#include <spot/tl/parse.hh>
|
||||||
|
#include <spot/misc/clz.hh>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -177,17 +178,7 @@ namespace spot
|
||||||
{
|
{
|
||||||
assert(n>0);
|
assert(n>0);
|
||||||
--n;
|
--n;
|
||||||
#ifdef __GNUC__
|
return CHAR_BIT*sizeof(unsigned) - clz(n);
|
||||||
return 8*sizeof(unsigned) - __builtin_clz(n);
|
|
||||||
#else
|
|
||||||
unsigned res = 0;
|
|
||||||
while (n)
|
|
||||||
{
|
|
||||||
++res;
|
|
||||||
n >>= 1;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static twa_graph_ptr
|
static twa_graph_ptr
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2018 Laboratoire de Recherche et Développement
|
// Copyright (C) 2018, 2021 Laboratoire de Recherche et Développement
|
||||||
// de l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
|
|
@ -359,19 +359,10 @@ namespace spot
|
||||||
auto v = data[i];
|
auto v = data[i];
|
||||||
if (v == 0)
|
if (v == 0)
|
||||||
{
|
{
|
||||||
res -= 8*sizeof(word_t);
|
res -= CHAR_BIT*sizeof(word_t);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef __GNUC__
|
return res + CHAR_BIT*sizeof(word_t) - clz(v) - 1;
|
||||||
res += 8*sizeof(word_t) - clz(v);
|
|
||||||
#else
|
|
||||||
while (v)
|
|
||||||
{
|
|
||||||
++res;
|
|
||||||
v >>= 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return res-1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue