Closed
Bug 94567
Opened 24 years ago
Closed 24 years ago
Avoid js_strlen() call in js_NewStringCopyZ()
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
VERIFIED
FIXED
mozilla0.9.4
People
(Reporter: bernard.alleysson, Assigned: brendan)
Details
(Keywords: js1.5, perf)
from jsstr.c rev 3.48
2298 JSString *
2299 js_NewStringCopyZ(JSContext *cx, const jschar *s, uintN gcflag)
2300 {
2301 size_t n, m;
2302 jschar *news;
2303 JSString *str;
2304
2305 n = js_strlen(s);
2306 m = (n + 1) * sizeof(jschar);
2307 news = (jschar *) JS_malloc(cx, m);
2308 if (!news)
2309 return NULL;
2310 memcpy(news, s, m);
2311 str = js_NewString(cx, news, js_strlen(news), gcflag);
2312 if (!str)
2313 JS_free(cx, news);
2314 return str;
2315 }
it seems that js_strlen(news) == js_strlen(s) == n since news is a copy of s
so the patch would be to replace
2311 str = js_NewString(cx, news, js_strlen(news), gcflag);
by
2311 str = js_NewString(cx, news, n, gcflag);
this will save a call to js_strlen
I know this is very little time but why waste cycles for that ?
| Assignee | ||
Comment 2•24 years ago
|
||
Dunno how that happened -- thanks for pointing it out.
/be
Assignee: rogerl → brendan
Keywords: js1.5,
mozilla0.9.4
Priority: -- → P3
Target Milestone: --- → mozilla0.9.4
Comment 3•24 years ago
|
||
r=shaver on the patch proposed by Bernard.
| Assignee | ||
Comment 4•24 years ago
|
||
sr=brendan@mozilla.org, and I checked in bernard's patch -- thanks!
/be
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•