Bug 26561 - Remove memcpy from ScriptSourceCode::source()
Summary: Remove memcpy from ScriptSourceCode::source()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-19 16:40 PDT by Adam Barth
Modified: 2009-06-20 02:21 PDT (History)
4 users (show)

See Also:


Attachments
patch (1.75 KB, patch)
2009-06-19 16:44 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
patch (1.75 KB, patch)
2009-06-19 16:46 PDT, Adam Barth
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2009-06-19 16:40:01 PDT
Darin worries that this memcpy might be slow.  Patch forthcoming.
Comment 1 Adam Barth 2009-06-19 16:44:10 PDT
Created attachment 31574 [details]
patch

Notice that the string is kept alive anyway because the
ScriptSourceCode holds a JSC::SourceCode which holds a RefPtr<SourceProvider>
which holds String m_source (via StringSourceProvider : public
JSC::SourceProvider).
Comment 2 Adam Barth 2009-06-19 16:46:17 PDT
Created attachment 31576 [details]
patch

Oops.  Forgot the const.
Comment 3 Darin Adler 2009-06-19 18:12:13 PDT
Comment on attachment 31574 [details]
patch

> +    // This same string is actually buried in m_code, but there isn't a clean
> +    // want to write an accessor for it, so we cache a refernce to it.
> +    String m_source;

"clean want"? How about "clean way"?

But I do think there is a clean way to get at it. Just add a source() member to StringSourceProvider, then call static_cast<StringSourceProvider*>(m_code->provider())->source().
Comment 4 Darin Adler 2009-06-19 18:12:47 PDT
Comment on attachment 31576 [details]
patch

It's not really buried all that deeply. I seriously think you could just do static_cast<StringSourceProvider*>(m_code->provider())->source(). r=me
Comment 5 Adam Barth 2009-06-20 01:14:24 PDT
> It's not really buried all that deeply. I seriously think you could just do
> static_cast<StringSourceProvider*>(m_code->provider())->source(). r=me

Ah.  I hadn't considered using a static_cast.  That should work.
Comment 6 Adam Barth 2009-06-20 02:21:40 PDT
Sending        WebCore/ChangeLog
Sending        WebCore/bindings/js/ScriptSourceCode.h
Sending        WebCore/bindings/js/StringSourceProvider.h
Transmitting file data ...
Committed revision 44894.