Closed Bug 409324 Opened 17 years ago Closed 17 years ago

js_DoubleToECMA(u)Int32 should return jsdouble, not a useless always-true JSBool

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Waldo, Assigned: sayrer)

References

Details

Attachments

(1 file, 2 obsolete files)

Attached patch change the return type (obsolete) — Splinter Review
Attachment #294238 - Flags: review?(brendan)
Comment on attachment 294238 [details] [diff] [review] change the return type >+js_DoubleToECMAInt32(jsdouble d) > { > jsdouble two32 = 4294967296.0; > jsdouble two31 = 2147483648.0; > > if (!JSDOUBLE_IS_FINITE(d) || d == 0) { >- *ip = 0; >- return JS_TRUE; >+ return 0; > } Nit: house style does not over-brace single-line consequents. >+ return (d >= two31) ? (d - two32) : d; Warning bait on some compilers? Previous code had (int32) cast to show intentional narrowing. >+uint32 >+js_DoubleToECMAUint32(jsdouble d) Same two comments apply to this function. r/a=me with those fixed, please set flags on final checked-in patch. Thanks, /be
Attachment #294238 - Flags: review?(brendan)
Attachment #294238 - Flags: review+
Attachment #294238 - Flags: approval1.9+
I saw Waldo suggesting a few more things on IRC... /be
Assignee: general → sayrer
local var elimination as suggested by waldo
Attachment #294238 - Attachment is obsolete: true
Attachment #294256 - Flags: review?(brendan)
Attachment #294238 - Flags: review+
Attachment #294238 - Flags: approval1.9+
Comment on attachment 294256 [details] [diff] [review] fix nits, eliminate some locals in jsparse.c Final nit: >+ return (int32) ((d >= two31) ? (d - two32) : d); No need to over-parenthesize the subtraction expression. r=me with that picked. /be
Attachment #294256 - Flags: review?(brendan) → review+
Attachment #294256 - Flags: approval1.9+
Attachment #294256 - Attachment is obsolete: true
Attachment #294280 - Flags: review+
Attachment #294280 - Flags: approval1.9+
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Is js_DoubleToECMAInt32 a special case or is this code pattern (function always returns true) something that should be eliminated in general? For example, js_ValueToBoolean could benefit from a similar makeover, too.
Blocks: 117611
Flags: in-testsuite-
Flags: in-litmus-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: