mirror of
https://github.com/vale981/arb
synced 2025-03-06 01:41:39 -05:00
de-inline clear() methods -> 8% faster compile, 25% smaller libarb.so
This commit is contained in:
parent
f168915ed6
commit
6316497cf5
8 changed files with 113 additions and 23 deletions
7
acb.h
7
acb.h
|
@ -48,12 +48,7 @@ acb_init(acb_t x)
|
||||||
arb_init(acb_imagref(x));
|
arb_init(acb_imagref(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
ACB_INLINE void
|
void acb_clear(acb_t x);
|
||||||
acb_clear(acb_t x)
|
|
||||||
{
|
|
||||||
arb_clear(acb_realref(x));
|
|
||||||
arb_clear(acb_imagref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ACB_INLINE acb_ptr
|
ACB_INLINE acb_ptr
|
||||||
_acb_vec_init(slong n)
|
_acb_vec_init(slong n)
|
||||||
|
|
37
acb/clear.c
Normal file
37
acb/clear.c
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2016 Fredrik Johansson
|
||||||
|
|
||||||
|
This file is part of Arb.
|
||||||
|
|
||||||
|
Arb is free software: you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||||
|
by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "acb.h"
|
||||||
|
|
||||||
|
/* The clear methods are not defined as inlines since this inflates
|
||||||
|
the code size. We inline the content manually here to avoid function
|
||||||
|
call overhead. Question: would calling arb_clear twice here be worth
|
||||||
|
the call overhead, by improving branch prediction? */
|
||||||
|
void
|
||||||
|
acb_clear(acb_t x)
|
||||||
|
{
|
||||||
|
ARF_DEMOTE(arb_midref(acb_realref(x)));
|
||||||
|
|
||||||
|
if (COEFF_IS_MPZ(ARF_EXP(arb_midref(acb_realref(x)))))
|
||||||
|
_fmpz_clear_mpz(ARF_EXP(arb_midref(acb_realref(x))));
|
||||||
|
|
||||||
|
if (COEFF_IS_MPZ(MAG_EXP(arb_radref(acb_realref(x)))))
|
||||||
|
_fmpz_clear_mpz(MAG_EXP(arb_radref(acb_realref(x))));
|
||||||
|
|
||||||
|
ARF_DEMOTE(arb_midref(acb_imagref(x)));
|
||||||
|
|
||||||
|
if (COEFF_IS_MPZ(ARF_EXP(arb_midref(acb_imagref(x)))))
|
||||||
|
_fmpz_clear_mpz(ARF_EXP(arb_midref(acb_imagref(x))));
|
||||||
|
|
||||||
|
if (COEFF_IS_MPZ(MAG_EXP(arb_radref(acb_imagref(x)))))
|
||||||
|
_fmpz_clear_mpz(MAG_EXP(arb_radref(acb_imagref(x))));
|
||||||
|
}
|
||||||
|
|
7
arb.h
7
arb.h
|
@ -54,12 +54,7 @@ arb_init(arb_t x)
|
||||||
mag_init(arb_radref(x));
|
mag_init(arb_radref(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
ARB_INLINE void
|
void arb_clear(arb_t x);
|
||||||
arb_clear(arb_t x)
|
|
||||||
{
|
|
||||||
arf_clear(arb_midref(x));
|
|
||||||
mag_clear(arb_radref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE arb_ptr
|
ARB_INLINE arb_ptr
|
||||||
_arb_vec_init(slong n)
|
_arb_vec_init(slong n)
|
||||||
|
|
28
arb/clear.c
Normal file
28
arb/clear.c
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2016 Fredrik Johansson
|
||||||
|
|
||||||
|
This file is part of Arb.
|
||||||
|
|
||||||
|
Arb is free software: you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||||
|
by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "arb.h"
|
||||||
|
|
||||||
|
/* The clear methods are not defined as inlines since this inflates
|
||||||
|
the code size. We inline the content manually here to avoid function
|
||||||
|
call overhead. */
|
||||||
|
void
|
||||||
|
arb_clear(arb_t x)
|
||||||
|
{
|
||||||
|
ARF_DEMOTE(arb_midref(x));
|
||||||
|
|
||||||
|
if (COEFF_IS_MPZ(ARF_EXP(arb_midref(x))))
|
||||||
|
_fmpz_clear_mpz(ARF_EXP(arb_midref(x)));
|
||||||
|
|
||||||
|
if (COEFF_IS_MPZ(MAG_EXP(arb_radref(x))))
|
||||||
|
_fmpz_clear_mpz(MAG_EXP(arb_radref(x)));
|
||||||
|
}
|
||||||
|
|
7
arf.h
7
arf.h
|
@ -228,12 +228,7 @@ arf_init(arf_t x)
|
||||||
ARF_XSIZE(x) = 0;
|
ARF_XSIZE(x) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ARF_INLINE void
|
void arf_clear(arf_t x);
|
||||||
arf_clear(arf_t x)
|
|
||||||
{
|
|
||||||
fmpz_clear(ARF_EXPREF(x));
|
|
||||||
ARF_DEMOTE(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
ARF_INLINE void
|
ARF_INLINE void
|
||||||
arf_zero(arf_t x)
|
arf_zero(arf_t x)
|
||||||
|
|
23
arf/clear.c
Normal file
23
arf/clear.c
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2016 Fredrik Johansson
|
||||||
|
|
||||||
|
This file is part of Arb.
|
||||||
|
|
||||||
|
Arb is free software: you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||||
|
by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "arf.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
arf_clear(arf_t x)
|
||||||
|
{
|
||||||
|
ARF_DEMOTE(x);
|
||||||
|
|
||||||
|
/* fmpz_clear(), but avoids a redundant store */
|
||||||
|
if (COEFF_IS_MPZ(ARF_EXP(x)))
|
||||||
|
_fmpz_clear_mpz(ARF_EXP(x));
|
||||||
|
}
|
||||||
|
|
6
mag.h
6
mag.h
|
@ -203,11 +203,7 @@ mag_init_set(mag_t x, const mag_t y)
|
||||||
MAG_MAN(x) = MAG_MAN(y);
|
MAG_MAN(x) = MAG_MAN(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
MAG_INLINE void
|
void mag_clear(mag_t x);
|
||||||
mag_clear(mag_t x)
|
|
||||||
{
|
|
||||||
fmpz_clear(MAG_EXPREF(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
MAG_INLINE void
|
MAG_INLINE void
|
||||||
mag_swap(mag_t x, mag_t y)
|
mag_swap(mag_t x, mag_t y)
|
||||||
|
|
21
mag/clear.c
Normal file
21
mag/clear.c
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2016 Fredrik Johansson
|
||||||
|
|
||||||
|
This file is part of Arb.
|
||||||
|
|
||||||
|
Arb is free software: you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||||
|
by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mag.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
mag_clear(mag_t x)
|
||||||
|
{
|
||||||
|
/* fmpz_clear(), but avoids a redundant store */
|
||||||
|
if (COEFF_IS_MPZ(MAG_EXP(x)))
|
||||||
|
_fmpz_clear_mpz(MAG_EXP(x));
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue