Fossil SCM
Put html_tag const table (from markdown implementation) in constant memory.
Commit
7c4414ca10e9f24216b7443f25dc89fb60d93447
Parent
cba6bbf89c45987…
1 file changed
+6
-6
+6
-6
| --- src/markdown.c | ||
| +++ src/markdown.c | ||
| @@ -161,11 +161,11 @@ | ||
| 161 | 161 | }; |
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | /* html_tag -- structure for quick HTML tag search (inspired from discount) */ |
| 165 | 165 | struct html_tag { |
| 166 | - char *text; | |
| 166 | + const char *text; | |
| 167 | 167 | int size; |
| 168 | 168 | }; |
| 169 | 169 | |
| 170 | 170 | |
| 171 | 171 | |
| @@ -172,11 +172,11 @@ | ||
| 172 | 172 | /******************** |
| 173 | 173 | * GLOBAL VARIABLES * |
| 174 | 174 | ********************/ |
| 175 | 175 | |
| 176 | 176 | /* block_tags -- recognised block tags, sorted by cmp_html_tag */ |
| 177 | -static struct html_tag block_tags[] = { | |
| 177 | +static const struct html_tag block_tags[] = { | |
| 178 | 178 | { "p", 1 }, |
| 179 | 179 | { "dl", 2 }, |
| 180 | 180 | { "h1", 2 }, |
| 181 | 181 | { "h2", 2 }, |
| 182 | 182 | { "h3", 2 }, |
| @@ -276,11 +276,11 @@ | ||
| 276 | 276 | return fossil_strnicmp(hta->text, htb->text, hta->size); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | |
| 280 | 280 | /* find_block_tag -- returns the current block tag */ |
| 281 | -static struct html_tag *find_block_tag(char *data, size_t size){ | |
| 281 | +static const struct html_tag *find_block_tag(const char *data, size_t size){ | |
| 282 | 282 | size_t i = 0; |
| 283 | 283 | struct html_tag key; |
| 284 | 284 | |
| 285 | 285 | /* looking for the word end */ |
| 286 | 286 | while( i<size |
| @@ -1070,11 +1070,11 @@ | ||
| 1070 | 1070 | /********************************* |
| 1071 | 1071 | * BLOCK-LEVEL PARSING FUNCTIONS * |
| 1072 | 1072 | *********************************/ |
| 1073 | 1073 | |
| 1074 | 1074 | /* is_empty -- returns the line length when it is empty, 0 otherwise */ |
| 1075 | -static size_t is_empty(char *data, size_t size){ | |
| 1075 | +static size_t is_empty(const char *data, size_t size){ | |
| 1076 | 1076 | size_t i; |
| 1077 | 1077 | for(i=0; i<size && data[i]!='\n'; i++){ |
| 1078 | 1078 | if( data[i]!=' ' && data[i]!='\t' ) return 0; |
| 1079 | 1079 | } |
| 1080 | 1080 | return i+1; |
| @@ -1631,11 +1631,11 @@ | ||
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | |
| 1634 | 1634 | /* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */ |
| 1635 | 1635 | /* returns the length on match, 0 otherwise */ |
| 1636 | -static size_t htmlblock_end(struct html_tag *tag, char *data, size_t size){ | |
| 1636 | +static size_t htmlblock_end(const struct html_tag *tag, const char *data, size_t size){ | |
| 1637 | 1637 | size_t i, w; |
| 1638 | 1638 | |
| 1639 | 1639 | /* assuming data[0]=='<' && data[1]=='/' already tested */ |
| 1640 | 1640 | |
| 1641 | 1641 | /* checking tag is a match */ |
| @@ -1668,11 +1668,11 @@ | ||
| 1668 | 1668 | struct render *rndr, |
| 1669 | 1669 | char *data, |
| 1670 | 1670 | size_t size |
| 1671 | 1671 | ){ |
| 1672 | 1672 | size_t i, j = 0; |
| 1673 | - struct html_tag *curtag; | |
| 1673 | + const struct html_tag *curtag; | |
| 1674 | 1674 | int found; |
| 1675 | 1675 | size_t work_size = 0; |
| 1676 | 1676 | struct Blob work = BLOB_INITIALIZER; |
| 1677 | 1677 | |
| 1678 | 1678 | /* identification of the opening tag */ |
| 1679 | 1679 |
| --- src/markdown.c | |
| +++ src/markdown.c | |
| @@ -161,11 +161,11 @@ | |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | /* html_tag -- structure for quick HTML tag search (inspired from discount) */ |
| 165 | struct html_tag { |
| 166 | char *text; |
| 167 | int size; |
| 168 | }; |
| 169 | |
| 170 | |
| 171 | |
| @@ -172,11 +172,11 @@ | |
| 172 | /******************** |
| 173 | * GLOBAL VARIABLES * |
| 174 | ********************/ |
| 175 | |
| 176 | /* block_tags -- recognised block tags, sorted by cmp_html_tag */ |
| 177 | static struct html_tag block_tags[] = { |
| 178 | { "p", 1 }, |
| 179 | { "dl", 2 }, |
| 180 | { "h1", 2 }, |
| 181 | { "h2", 2 }, |
| 182 | { "h3", 2 }, |
| @@ -276,11 +276,11 @@ | |
| 276 | return fossil_strnicmp(hta->text, htb->text, hta->size); |
| 277 | } |
| 278 | |
| 279 | |
| 280 | /* find_block_tag -- returns the current block tag */ |
| 281 | static struct html_tag *find_block_tag(char *data, size_t size){ |
| 282 | size_t i = 0; |
| 283 | struct html_tag key; |
| 284 | |
| 285 | /* looking for the word end */ |
| 286 | while( i<size |
| @@ -1070,11 +1070,11 @@ | |
| 1070 | /********************************* |
| 1071 | * BLOCK-LEVEL PARSING FUNCTIONS * |
| 1072 | *********************************/ |
| 1073 | |
| 1074 | /* is_empty -- returns the line length when it is empty, 0 otherwise */ |
| 1075 | static size_t is_empty(char *data, size_t size){ |
| 1076 | size_t i; |
| 1077 | for(i=0; i<size && data[i]!='\n'; i++){ |
| 1078 | if( data[i]!=' ' && data[i]!='\t' ) return 0; |
| 1079 | } |
| 1080 | return i+1; |
| @@ -1631,11 +1631,11 @@ | |
| 1631 | } |
| 1632 | |
| 1633 | |
| 1634 | /* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */ |
| 1635 | /* returns the length on match, 0 otherwise */ |
| 1636 | static size_t htmlblock_end(struct html_tag *tag, char *data, size_t size){ |
| 1637 | size_t i, w; |
| 1638 | |
| 1639 | /* assuming data[0]=='<' && data[1]=='/' already tested */ |
| 1640 | |
| 1641 | /* checking tag is a match */ |
| @@ -1668,11 +1668,11 @@ | |
| 1668 | struct render *rndr, |
| 1669 | char *data, |
| 1670 | size_t size |
| 1671 | ){ |
| 1672 | size_t i, j = 0; |
| 1673 | struct html_tag *curtag; |
| 1674 | int found; |
| 1675 | size_t work_size = 0; |
| 1676 | struct Blob work = BLOB_INITIALIZER; |
| 1677 | |
| 1678 | /* identification of the opening tag */ |
| 1679 |
| --- src/markdown.c | |
| +++ src/markdown.c | |
| @@ -161,11 +161,11 @@ | |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | /* html_tag -- structure for quick HTML tag search (inspired from discount) */ |
| 165 | struct html_tag { |
| 166 | const char *text; |
| 167 | int size; |
| 168 | }; |
| 169 | |
| 170 | |
| 171 | |
| @@ -172,11 +172,11 @@ | |
| 172 | /******************** |
| 173 | * GLOBAL VARIABLES * |
| 174 | ********************/ |
| 175 | |
| 176 | /* block_tags -- recognised block tags, sorted by cmp_html_tag */ |
| 177 | static const struct html_tag block_tags[] = { |
| 178 | { "p", 1 }, |
| 179 | { "dl", 2 }, |
| 180 | { "h1", 2 }, |
| 181 | { "h2", 2 }, |
| 182 | { "h3", 2 }, |
| @@ -276,11 +276,11 @@ | |
| 276 | return fossil_strnicmp(hta->text, htb->text, hta->size); |
| 277 | } |
| 278 | |
| 279 | |
| 280 | /* find_block_tag -- returns the current block tag */ |
| 281 | static const struct html_tag *find_block_tag(const char *data, size_t size){ |
| 282 | size_t i = 0; |
| 283 | struct html_tag key; |
| 284 | |
| 285 | /* looking for the word end */ |
| 286 | while( i<size |
| @@ -1070,11 +1070,11 @@ | |
| 1070 | /********************************* |
| 1071 | * BLOCK-LEVEL PARSING FUNCTIONS * |
| 1072 | *********************************/ |
| 1073 | |
| 1074 | /* is_empty -- returns the line length when it is empty, 0 otherwise */ |
| 1075 | static size_t is_empty(const char *data, size_t size){ |
| 1076 | size_t i; |
| 1077 | for(i=0; i<size && data[i]!='\n'; i++){ |
| 1078 | if( data[i]!=' ' && data[i]!='\t' ) return 0; |
| 1079 | } |
| 1080 | return i+1; |
| @@ -1631,11 +1631,11 @@ | |
| 1631 | } |
| 1632 | |
| 1633 | |
| 1634 | /* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */ |
| 1635 | /* returns the length on match, 0 otherwise */ |
| 1636 | static size_t htmlblock_end(const struct html_tag *tag, const char *data, size_t size){ |
| 1637 | size_t i, w; |
| 1638 | |
| 1639 | /* assuming data[0]=='<' && data[1]=='/' already tested */ |
| 1640 | |
| 1641 | /* checking tag is a match */ |
| @@ -1668,11 +1668,11 @@ | |
| 1668 | struct render *rndr, |
| 1669 | char *data, |
| 1670 | size_t size |
| 1671 | ){ |
| 1672 | size_t i, j = 0; |
| 1673 | const struct html_tag *curtag; |
| 1674 | int found; |
| 1675 | size_t work_size = 0; |
| 1676 | struct Blob work = BLOB_INITIALIZER; |
| 1677 | |
| 1678 | /* identification of the opening tag */ |
| 1679 |