Bug 86307 - Simplify SourceProvider's subclasses
Summary: Simplify SourceProvider's subclasses
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-12 17:17 PDT by Benjamin Poulain
Modified: 2012-09-01 17:51 PDT (History)
0 users

See Also:


Attachments
Patch (7.01 KB, patch)
2012-05-12 19:17 PDT, Benjamin Poulain
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2012-05-12 17:17:32 PDT
Simplify SourceProvider's subclasses
Comment 1 Benjamin Poulain 2012-05-12 19:17:14 PDT
Created attachment 141591 [details]
Patch
Comment 2 Darin Adler 2012-05-13 15:59:03 PDT
Comment on attachment 141591 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=141591&action=review

This is OK as-is, but we might be able to do a bit better.

> Source/JavaScriptCore/parser/SourceProvider.h:61
> +        const StringImpl* data() const
> +        {
> +            return stringImpl();
> +        }

Why not leave this as a pure virtual function and call it instead of adding a new stringImpl() function? Or maybe this could all be done with the source() function? I am unclear on why there need to be three different functions that all return the source string.

Also, all the callers seem to be calling impl() so maybe this should return a const UString& or const String&. That would be one way of saving a bit of reference count churn in the getRange function. I guess the source() function already works that way.

> Source/JavaScriptCore/parser/SourceProvider.h:65
> +            int length = end - start;

Why a local variable for this? Doesn’t seem better than just saying end - start in the function call.

> Source/JavaScriptCore/parser/SourceProvider.h:66
> +            return UString(stringImpl()).substringSharingImpl(start, length);

Would be nice to add a version of substringSharingImpl that works directly on a StringImpl* so we don’t have to churn the reference count an extra time each time this function is called.

> Source/JavaScriptCore/parser/SourceProvider.h:72
> +            StringImpl* impl = stringImpl();
> +            return impl ? impl->length() : 0;

There must be a better name than “impl” for this. Maybe “data” or “string”. Words are better than word fragments.
Comment 3 Benjamin Poulain 2012-05-16 16:40:26 PDT
The method source() is actually WebCore specific. Generalizing it to JSC is a good idea, I will look into that.
Comment 4 Benjamin Poulain 2012-09-01 17:51:39 PDT
With the UString change, this problem has radically changed.

I close this bug as it is now  superseded by https://bugs.webkit.org/show_bug.cgi?id=95635