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
39 39
40static int parse_str_int(const uint8_t *p, const uint8_t *end, const uint8_t *key)40static int parse_str_int(const uint8_t *p, const uint8_t *end, const uint8_t *key)
41{41{
42 for(; p<end - strlen(key); p++) {42 int keylen = strlen(key);
43 if (!memcmp(p, key, strlen(key)))43 const uint8_t *e = end - keylen;
44
45 for(; p < e; p++) {
46 if (!memcmp(p, key, keylen))
44 break;47 break;
45 }48 }
46 p += strlen(key);49 p += keylen;
47 if (p >= end)50 if (p >= end)
48 return INT_MIN;51 return INT_MIN;
49 52

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