Re: [dev] [st] [PATCH] Explicit cast in CEIL macro

From: FRIGN <dev_AT_frign.de>
Date: Mon, 23 Jun 2014 14:53:31 +0200

On Mon, 23 Jun 2014 09:32:09 +0200
"Roberto E. Vargas Caballero" <k0ga_AT_shike2.com> wrote:

> For me it is ok to, but I think we are losing the point here. Why st has a
> macro called CEIL instead of using ceil?, because it is used only with
> integers, and in this case is faster use CEIL instead of calling ceil (with
> or without tgmath.h). So the point is, do we need this optimization?

No, this is wrong.
Check cwscale and chscale in config.h, which are floats.

        xw.cw = CEIL(dc.font.width * cwscale);
        xw.ch = CEIL(dc.font.height * chscale);

dc.font.width and dc.font.height are integers, but CEIL exlusively
deals with floats.

However, after further investigation, I also conclude including math.h
is not necessary.
We may then substitute CEIL with ceilf, but this would imply
refactoring other macros too.
Given this very limited use-case which doesn't add much complexity to
the program (CEIL is a very simple macro), including math.h is overkill.

Cheers

FRIGN

-- 
FRIGN <dev_AT_frign.de>
Received on Mon Jun 23 2014 - 14:53:31 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 23 2014 - 15:00:13 CEST