forked from len0rd/rockbox
skin engine small cleanup optimize find_tag() remove string copy
since we now have the length of tag names thru the param_pos var we can simplify the find tag function to skip if the length doesn't match this allows us to no longer make a string copy in order to terminate the buffer move some of the more frequently encountered tags to the top of the lookup list only SKIN_TOKEN_UNKNOWN position matters as its empty string is used as the sentinel Change-Id: Ib82d081a9ebedc228768845ae54a3d9466faaef1
This commit is contained in:
parent
303fc090a7
commit
ff9da12763
4 changed files with 90 additions and 90 deletions
|
@ -501,7 +501,6 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
|
|||
const char* bookmark;
|
||||
const char *open_square_bracket = NULL;
|
||||
|
||||
char tag_name[MAX_TAG_LENGTH];
|
||||
const char* tag_args;
|
||||
const struct tag_info *tag;
|
||||
struct skin_tag_parameter* params = NULL;
|
||||
|
@ -513,25 +512,14 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
|
|||
int optional = 0;
|
||||
|
||||
/* Checking the tag name */
|
||||
for (i=0; cursor[i] && i<MAX_TAG_LENGTH; i++)
|
||||
tag_name[i] = cursor[i];
|
||||
|
||||
/* First we check the two characters after the '%', then a single char */
|
||||
tag = NULL;
|
||||
i = MAX_TAG_LENGTH;
|
||||
while (!tag && i > 1)
|
||||
{
|
||||
tag_name[i-1] = '\0';
|
||||
tag = find_tag(tag_name);
|
||||
i--;
|
||||
}
|
||||
tag = find_tag(cursor);
|
||||
|
||||
if(!tag)
|
||||
{
|
||||
skin_error(ILLEGAL_TAG, cursor);
|
||||
return 0;
|
||||
}
|
||||
cursor += i;
|
||||
cursor += tag->param_pos - 1; /*strlen(tag->name)*/;
|
||||
|
||||
/* Copying basic tag info */
|
||||
if(element->type != CONDITIONAL && element->type != VIEWPORT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue