From 03a73f928276eed10d5fdb0046614b47f0bba595 Mon Sep 17 00:00:00 2001 From: maya Date: Sat, 31 Dec 2016 15:33:03 +0000 Subject: [PATCH] Spare ourselves a fabs call. We already check the sign later. w = r + y*I is the same as w = r because this is the y == 0 case. no functional change. --- lib/libm/complex/csqrt.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/libm/complex/csqrt.c b/lib/libm/complex/csqrt.c index f9267ec13df9..480927406902 100644 --- a/lib/libm/complex/csqrt.c +++ b/lib/libm/complex/csqrt.c @@ -1,4 +1,4 @@ -/* $NetBSD: csqrt.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */ +/* $NetBSD: csqrt.c,v 1.2 2016/12/31 15:33:03 maya Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -45,23 +45,24 @@ csqrt(double complex z) if (x == 0.0) { w = 0.0 + y * I; } else { - r = fabs(x); - r = sqrt(r); if (x < 0.0) { + r = sqrt(-x); w = 0.0 + r * I; } else { - w = r + y * I; + r = sqrt(x); + w = r; } } return w; } if (x == 0.0) { - r = fabs(y); - r = sqrt(0.5 * r); - if (y > 0) + if (y > 0) { + r = sqrt(0.5 * y); w = r + r * I; - else + } else { + r = sqrt(-0.5 * y); w = r - r * I; + } return w; } /* Rescale to avoid internal overflow or underflow. */