[webkit-dev] converting by constructor

Adam Barth abarth at webkit.org
Mon May 17 17:42:43 PDT 2010

On Mon, May 17, 2010 at 5:28 PM, Chris Jerdonek <cjerdonek at webkit.org> wrote:
> On Mon, May 17, 2010 at 3:11 PM, Darin Adler <darin at apple.com> wrote:
>> I think the best way for us to clarify our guideline for this would be to discuss a few individual cases where we have a non-explicit constructor. We can talk about why they are not explicit and see if we find they are just bugs or show a principle at work.
> I wasn't intending to create a formal guideline, but one example I encountered
> recently is ResourceRequest, which has String and KURL single-parameter
> constructors without the explicit keyword.
> The FrameLoader class has about 25 methods that accept a ResourceRequest
> (e.g. various load methods), so all of these also accept a String and
> KURL.  This makes it harder to know the right way these methods
> should be getting called.  This also makes it harder to refactor.  Call
> sites seem to use all three variations.

Ouch.  That sounds like a bug.  :)

> The class also has other load-like
> methods that accept a String url, and others that accept a KURL url.

Yeah, the whole String/KURL representation of a url issue is something
we'd like to clean up at some point too.  One of the considerations
here is that KURL takes more memory than String to represent a URL.
We'd like to measure and see how big an effect that is.

One thing we could do in the intermediate term is use the type
URLString for URLs that we store as Strings.  This change wouldn't
affect the compiled code, but it would help us keep track of what's
going on better and pave the way for further changes in the future.  I
wrote a patch that started to do this, but the discussion got a bit
sidetracked into the larger questions surrounding how to represent



More information about the webkit-dev mailing list