WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
98299
String::remove will convert an 8 bit string to a 16 bit string
https://bugs.webkit.org/show_bug.cgi?id=98299
Summary
String::remove will convert an 8 bit string to a 16 bit string
Michael Saboff
Reported
2012-10-03 14:16:09 PDT
The StringImpl::remove() method will up convert the contents of an 8 bit string and the result will always be a 16 bit string.
Attachments
Patch
(1.92 KB, patch)
2012-10-03 16:00 PDT
,
Michael Saboff
benjamin
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Michael Saboff
Comment 1
2012-10-03 14:19:41 PDT
The remove method is actually in WTFString.cpp (String::remove).
Michael Saboff
Comment 2
2012-10-03 16:00:05 PDT
Created
attachment 166981
[details]
Patch
Benjamin Poulain
Comment 3
2012-10-03 17:43:16 PDT
Comment on
attachment 166981
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=166981&action=review
> Source/WTF/wtf/text/WTFString.cpp:281 > if (static_cast<unsigned>(lengthToRemove) > length() - position) > lengthToRemove = length() - position;
No idea if that case is common. If it is, shouldn't we just return a substring sharing impl here?
> Source/WTF/wtf/text/WTFString.cpp:289 > + RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() - lengthToRemove, data); > + memcpy(data, characters8(), position * sizeof(LChar)); > + memcpy(data + position, characters8() + position + lengthToRemove, > + (length() - lengthToRemove - position) * sizeof(LChar)); > + m_impl = newImpl.release();
I would do an inline template with that code taking CharacterType as argument.
Michael Saboff
Comment 4
2012-10-04 09:44:35 PDT
(In reply to
comment #3
)
> (From update of
attachment 166981
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=166981&action=review
> > > Source/WTF/wtf/text/WTFString.cpp:281 > > if (static_cast<unsigned>(lengthToRemove) > length() - position) > > lengthToRemove = length() - position; > > No idea if that case is common. > If it is, shouldn't we just return a substring sharing impl here?
From what I've seen, the use of remove is within length range and this wouldn't help.
> > Source/WTF/wtf/text/WTFString.cpp:289 > > + RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() - lengthToRemove, data); > > + memcpy(data, characters8(), position * sizeof(LChar)); > > + memcpy(data + position, characters8() + position + lengthToRemove, > > + (length() - lengthToRemove - position) * sizeof(LChar)); > > + m_impl = newImpl.release(); > > I would do an inline template with that code taking CharacterType as argument.
Done.
Michael Saboff
Comment 5
2012-10-04 09:45:17 PDT
Committed
r130404
: <
http://trac.webkit.org/changeset/130404
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug