summaryrefslogtreecommitdiff
path: root/src/util/floatingpoint.cpp
diff options
context:
space:
mode:
authorAina Niemetz <aina.niemetz@gmail.com>2021-03-19 10:28:14 -0700
committerGitHub <noreply@github.com>2021-03-19 17:28:14 +0000
commit58e219362b2e9a7d7b9b9b526760c392cd50e878 (patch)
treeedc5b6e8f4307942a914d13c218197328c8cb6bf /src/util/floatingpoint.cpp
parent95f5be640fd362098a54e222d56d49144fe0efbe (diff)
BitVector: Change setBit to set the bit in place. (#6176)
Creating BitVectors (and deleting them) is in general expensive because of the underlying multi-precision Integer. If possible, unnecessary constructions and desctructions of BitVectors should be avoided. The most common use case for `setBit` is that for an existing BitVector, a given bit should be set to a certain value. Not doing this in place generates unnecessary constructions and destructions of BitVectors.
Diffstat (limited to 'src/util/floatingpoint.cpp')
-rw-r--r--src/util/floatingpoint.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/floatingpoint.cpp b/src/util/floatingpoint.cpp
index 42f411ab2..cebdbbb29 100644
--- a/src/util/floatingpoint.cpp
+++ b/src/util/floatingpoint.cpp
@@ -361,8 +361,8 @@ FloatingPoint FloatingPoint::makeMaxNormal(const FloatingPointSize& size,
bool sign)
{
BitVector bvsign = sign ? BitVector::mkOne(1) : BitVector::mkZero(1);
- BitVector bvexp =
- BitVector::mkOnes(size.packedExponentWidth()).setBit(0, false);
+ BitVector bvexp = BitVector::mkOnes(size.packedExponentWidth());
+ bvexp.setBit(0, false);
BitVector bvsig = BitVector::mkOnes(size.packedSignificandWidth());
return FloatingPoint(size, bvsign.concat(bvexp).concat(bvsig));
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback