[Webkit-unassigned] [Bug 28355] Replace MAX()/MIN() macros with type-safe std::max()/min() templates

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Aug 16 10:10:16 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=28355


mitz at webkit.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #34925|review?                     |review+
               Flag|                            |




--- Comment #1 from mitz at webkit.org  2009-08-16 10:10:15 PDT ---
(From update of attachment 34925)
> +        <http://webkit.org/b/00000> Replace MAX()/MIN() macros with type-safe std::max()/min() templates

Presumably this will transform into this bug’s URL?

> +        * platform/graphics/mac/SimpleFontDataMac.mm: Added using
> +        std::max statment.

Typo: statment.

In new files, it is common to just add “using namespace std;”.

> +        <http://webkit.org/b/00000> Replace MAX()/MIN() macros with type-safe std::max()/min() templates

URL…

> +            deliveryBytes = static_cast<int32>(min(static_cast<NSUInteger>(deliveryBytes), [subdata length]));

This is an odd combination of casts. You can do “min<int32>(deliveryBytes,
[subdata length])” instead.

> -                    dataLength = MIN((unsigned)[contentLength intValue], dataLength);
> +                    dataLength = min(static_cast<unsigned>([contentLength intValue]), dataLength);

I prefer min<unsigned>(…).

> -            imageSize.width = MAX(MAX_DRAG_LABEL_WIDTH + DRAG_LABEL_BORDER_X * 2.0f, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP);
> +            imageSize.width = max(MAX_DRAG_LABEL_WIDTH + DRAG_LABEL_BORDER_X * 2.0f, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP);

While you’re here, you may just drop the “.0f”.

> -            imageSize.width = MAX(labelSize.width + DRAG_LABEL_BORDER_X * 2.0f, urlStringSize.width + DRAG_LABEL_BORDER_X * 2.0f);
> +            imageSize.width = max(labelSize.width + DRAG_LABEL_BORDER_X * 2.0f, urlStringSize.width + DRAG_LABEL_BORDER_X * 2.0f);

Ditto.

> +        maxWidth = min(static_cast<CGFloat>(400), windowFrame.size.width);

Can be done as min<CGFloat>(…).

r=me but please consider at least changing to “using namespace std;”.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list