RESOLVED FIXED 6900
apply Vector class to KURL
https://bugs.webkit.org/show_bug.cgi?id=6900
Summary apply Vector class to KURL
Maciej Stachowiak
Reported 2006-01-28 20:46:38 PST
KURL should use Vector for its stack buffers, and in place of Array.
Attachments
apply Vector to KURL (12.44 KB, patch)
2006-01-28 21:09 PST, Maciej Stachowiak
darin: review+
Maciej Stachowiak
Comment 1 2006-01-28 21:09:06 PST
Created attachment 6062 [details] apply Vector to KURL I ran performance tests and found no regression. Also all the layout tests pass.
Darin Adler
Comment 2 2006-01-28 21:14:10 PST
Comment on attachment 6062 [details] apply Vector to KURL Looks good. r=me
David Kilzer (:ddkilzer)
Comment 3 2006-01-29 06:09:08 PST
Comment on attachment 6062 [details] apply Vector to KURL >Index: kwq/KWQKURL.mm >=================================================================== >--- kwq/KWQKURL.mm (revision 12427) >+++ kwq/KWQKURL.mm (working copy) >@@ -238,15 +231,9 @@ KURL::KURL() : m_isValid(false) > KURL::KURL(const char *url) > { > if (url && url[0] == '/') { >- char staticBuffer[2048]; >- char *buffer; >+ // 5 for "file:", 1 for terminator > size_t urlLength = strlen(url) + 1; >- size_t bufferLength = urlLength + 5; // 5 for "file:" >- if (bufferLength > sizeof(staticBuffer)) { >- buffer = (char *)fastMalloc(bufferLength); >- } else { >- buffer = staticBuffer; >- } >+ Vector<char, 2048> buffer(urlLength + 5); > buffer[0] = 'f'; > buffer[1] = 'i'; > buffer[2] = 'l'; Shouldn't the "5" be a "6" in the new Vector declaration above? Also, it seems that every time that Vector is used, a "1" must be explicitly added for the terminator character. Wouldn't it be best to pull this behavior back into the template class and automatically add 1 for the caller?
David Kilzer (:ddkilzer)
Comment 4 2006-01-29 06:09:28 PST
Reopening per Comment #3.
David Kilzer (:ddkilzer)
Comment 5 2006-01-29 19:46:13 PST
(In reply to comment #3) > Shouldn't the "5" be a "6" in the new Vector declaration above? FYI, the "+ 1" is added on the line above, so this isn't an issue.
Note You need to log in before you can comment on or make changes to this bug.