WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
33189
scaleEmToUnits in SimpleFontDataMac.mm does an unnecessary division
https://bugs.webkit.org/show_bug.cgi?id=33189
Summary
scaleEmToUnits in SimpleFontDataMac.mm does an unnecessary division
Ojan Vafai
Reported
2010-01-04 17:01:14 PST
It's not a big deal, but I stumbled upon it and thought I'd clean it up. const float contextDPI = 72.0f; static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x * (contextDPI / (contextDPI * unitsPerEm)); } can just be static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x / static_cast<float>(unitsPerEm); } Technically, there could be minor differences here due to float rounding I think, but in practice I think this is just an accident of history. The code was added here
http://trac.webkit.org/changeset/8104
. I assume this was done to match the previously private function, but we don't use that function anymore. In either case, the layout tests pass with this change.
Attachments
2010-01-04 Nikolas Zimmermann <nzimmermann@rim.com>
(1.05 KB, patch)
2010-01-04 17:36 PST
,
Ojan Vafai
darin
: review-
Details
Formatted Diff
Diff
Remove unnecessary division
(1.55 KB, patch)
2010-01-04 17:39 PST
,
Ojan Vafai
no flags
Details
Formatted Diff
Diff
Patch without static_cast.
(1.55 KB, patch)
2010-01-04 18:12 PST
,
Ojan Vafai
no flags
Details
Formatted Diff
Diff
Patch without static_cast for real this time.
(1.53 KB, patch)
2010-01-04 18:50 PST
,
Ojan Vafai
mitz: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Ojan Vafai
Comment 1
2010-01-04 17:36:36 PST
Created
attachment 45847
[details]
2010-01-04 Nikolas Zimmermann <
nzimmermann@rim.com
>
Darin Adler
Comment 2
2010-01-04 17:37:23 PST
Comment on
attachment 45847
[details]
2010-01-04 Nikolas Zimmermann <
nzimmermann@rim.com
> Looks like this is the wrong patch.
Ojan Vafai
Comment 3
2010-01-04 17:38:42 PST
Comment on
attachment 45847
[details]
2010-01-04 Nikolas Zimmermann <
nzimmermann@rim.com
> Holy cow that was fast. I was just marking this patch obsolete! Bugzilla-tool post-commits is confusing. head~1 really should be the top commit, not the second one. Sorry for the spam.
Ojan Vafai
Comment 4
2010-01-04 17:39:31 PST
Created
attachment 45849
[details]
Remove unnecessary division
Darin Adler
Comment 5
2010-01-04 18:01:48 PST
Comment on
attachment 45849
[details]
Remove unnecessary division
> -static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x * (contextDPI / (contextDPI * unitsPerEm)); } > +static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x / static_cast<float>(unitsPerEm); }
Why the static_cast<float>? As far as I know, C will do a float / unsigned just fine, and return a float without any cast.
WebKit Review Bot
Comment 6
2010-01-04 18:04:49 PST
style-queue ran check-webkit-style on
attachment 45849
[details]
without any errors.
Ojan Vafai
Comment 7
2010-01-04 18:12:09 PST
Created
attachment 45854
[details]
Patch without static_cast.
Ojan Vafai
Comment 8
2010-01-04 18:13:11 PST
(In reply to
comment #5
)
> (From update of
attachment 45849
[details]
) > > -static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x * (contextDPI / (contextDPI * unitsPerEm)); } > > +static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x / static_cast<float>(unitsPerEm); } > > Why the static_cast<float>? As far as I know, C will do a float / unsigned just > fine, and return a float without any cast.
I was just mimicking code used in the other platform's versions of scaleEmToUnits. Removed.
Ojan Vafai
Comment 9
2010-01-04 18:50:23 PST
Created
attachment 45856
[details]
Patch without static_cast for real this time.
mitz
Comment 10
2010-01-04 18:58:47 PST
Comment on
attachment 45856
[details]
Patch without static_cast for real this time.
> + Need a short description and bug URL (OOPS!)
Please remove that line.
> + No new tests. Covered by existing tests.
More like this code change does not change behavior.
Ojan Vafai
Comment 11
2010-01-04 19:56:53 PST
http://trac.webkit.org/changeset/52782
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug