History

avcodec/xbmenc: Pre-compute variables once for parse_str_int()

Some compilers are very intuitive, and others are not so much, so let's pre-compute the variables e and keylen outside the for loop. Ensuring a minor speed increase regardless of if compiler is smart enough to solve this improvement for itself, or not.

Jose Da Silva committed 5 years ago

Commit 42c636c1 parent b6bc9811 file · +6 −3Browse files

Unified · Split

libavcodec/xbmdec.c+6−3
@@ -39,11 +39,14 @@ static int convert(uint8_t x) · 38 unmodified lines
3939
4040 static int parse_str_int(const uint8_t *p, const uint8_t *end, const uint8_t *key)
4141 {
42− for(; p<end - strlen(key); p++) {
43− if (!memcmp(p, key, strlen(key)))
42+ int keylen = strlen(key);
43+ const uint8_t *e = end - keylen;
44+
45+ for(; p < e; p++) {
46+ if (!memcmp(p, key, keylen))
4447 break;
4548 }
46− p += strlen(key);
49+ p += keylen;
4750 if (p >= end)
4851 return INT_MIN;
4952

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t