Bug 74771 - Remove the duplicated code from ASCIICType.h
Summary: Remove the duplicated code from ASCIICType.h
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-16 17:16 PST by Benjamin Poulain
Modified: 2011-12-18 22:04 PST (History)
1 user (show)

See Also:


Attachments
Patch (12.13 KB, patch)
2011-12-16 17:19 PST, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (2.12 KB, patch)
2011-12-16 23:14 PST, Benjamin Poulain
kling: 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 2011-12-16 17:16:52 PST
ASCIICType.h is just a bunch of function copied for every type. I have heard of that template thingy that is good at doing that ;)
Comment 1 Benjamin Poulain 2011-12-16 17:19:53 PST
Created attachment 119703 [details]
Patch
Comment 2 Benjamin Poulain 2011-12-16 17:23:31 PST
I was also curious why we need to support so many types and not just UChar for every function... It is because of the JSC::Yarr() and JSC::lexer(), which use various types for the characters.

This could probably be fixed but I preferred to limit the scope of this particular change.
Comment 3 Andreas Kling 2011-12-16 21:56:42 PST
Comment on attachment 119703 [details]
Patch

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

Great idea!

> Source/JavaScriptCore/ChangeLog:8
> +        The functions were sharing similar code and were defined for the various input type.

type -> types

> Source/JavaScriptCore/ChangeLog:9
> +        Use template instead to avoid code duplication.

template -> templates

> Source/JavaScriptCore/wtf/ASCIICType.h:98
> + character          count
> + ---------          -----
> + non-spaces         689383
> + 20  space              294720
> + 0A  \n                 89059
> + 09  \t                 28320
> + 0D  \r                 0
> + 0C  \f                 0
> + 0B  \v                 0
> + */

Looks like you're breaking the alignment here a bit.
Comment 4 Benjamin Poulain 2011-12-16 22:36:22 PST
Committed r103144: <http://trac.webkit.org/changeset/103144>
Comment 5 Benjamin Poulain 2011-12-16 22:56:21 PST
Reopen, I am not finished here :)
Comment 6 Benjamin Poulain 2011-12-16 23:14:21 PST
Created attachment 119715 [details]
Patch
Comment 7 Andreas Kling 2011-12-17 09:12:40 PST
Comment on attachment 119715 [details]
Patch

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

> Source/JavaScriptCore/wtf/ASCIICType.h:58
> +    return (c >= '0') && (c <= '9');

You don't need parentheses here. NABD.
Comment 8 Benjamin Poulain 2011-12-18 18:06:09 PST
Committed r103202: <http://trac.webkit.org/changeset/103202>
Comment 9 Benjamin Poulain 2011-12-18 18:06:35 PST
(In reply to comment #7)
> > Source/JavaScriptCore/wtf/ASCIICType.h:58
> > +    return (c >= '0') && (c <= '9');
> 
> You don't need parentheses here. NABD.

I know, but I like the parentheses :)

The helmet is not mandatory when rollerblading(*), but it is safer ;)


(*) restrictions may apply depending on your country. The lack of helmet can have side effects including nausea, headache or death. If you feel any discomfort, immediately consult a doctor.
Comment 10 Alexey Proskuryakov 2011-12-18 21:59:59 PST
The first patch is marked as obsolete. Was it rolled out? If it's in the tree, it should not be obsolete, as otherwise it's too hard to see what changes the bug included.
Comment 11 Benjamin Poulain 2011-12-18 22:04:08 PST
(In reply to comment #10)
> The first patch is marked as obsolete. Was it rolled out? If it's in the tree, it should not be obsolete, as otherwise it's too hard to see what changes the bug included.

You are right. I used webkit-patch without thinking about that.