Closed Bug 564980 Opened 16 years ago Closed 16 years ago

[FIX]Use JSString::length directly instead of via JS_GetStringLength

Categories

(Core :: XPConnect, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

That should save us the function call overhead on hot paths.
Attached patch Like so — — Splinter Review
Attachment #444591 - Flags: review?(mrbkap)
Comment on attachment 444591 [details] [diff] [review] Like so + nsDependentString(reinterpret_cast<const PRUnichar *>(::JS_GetStringChars(str)), + str->length()) Any reason not to replace the JS_GetStringChars() call with str->chars() as well (which this bug seems to be primarily about)?
Comment on attachment 444591 [details] [diff] [review] Like so I have the same question as jst -- either this bug is mistitled, or there's more function call overhead to nuke here.
Attachment #444591 - Flags: review?(mrbkap)
Just looked over the profiles again. I'd started with JS_GetStringChars (which showed up more than JS_GetStringLength), then realized that I can't just call chars() because I can't link to js_GetDependentStringChars (it's not exported) and just converted JS_GetStringLength. I suppose I can retitle or we can wontfix or whatever. Or make js_GetDependentStringChars a friend API?
Comment on attachment 444591 [details] [diff] [review] Like so I guess that we might as well do this... It can't hurt any more than our existing uses of friendly APIs.
Attachment #444591 - Flags: review+
Summary: [FIX]Use JSString::chars directly instead of via JS_GetStringChars → [FIX]Use JSString::length directly instead of via JS_GetStringLength
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: