aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-06-13 03:43:07 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-06-13 03:43:07 -0300
commit9ec90abdabefba18b8bd65392f539f5da7e4f37b (patch)
tree595391c80ae80dcdebbf1dd8b3175cae1525687f /src
parentb2747f5164d93bf9a686ddec273838db855113a0 (diff)
downloadblogc-9ec90abdabefba18b8bd65392f539f5da7e4f37b.tar.gz
blogc-9ec90abdabefba18b8bd65392f539f5da7e4f37b.tar.bz2
blogc-9ec90abdabefba18b8bd65392f539f5da7e4f37b.zip
source-parse: optimize excerpt usage
Diffstat (limited to 'src')
-rw-r--r--src/source-parser.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/source-parser.c b/src/source-parser.c
index 050082f..5c9d41d 100644
--- a/src/source-parser.c
+++ b/src/source-parser.c
@@ -42,6 +42,7 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)
char *key = NULL;
char *tmp = NULL;
+ char *content = NULL;
b_trie_t *rv = b_trie_new(free);
blogc_source_parser_state_t state = SOURCE_START;
@@ -149,13 +150,10 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)
if (current == (src_len - 1)) {
tmp = b_strndup(src + start, src_len - start);
b_trie_insert(rv, "RAW_CONTENT", tmp);
- b_trie_insert(rv, "CONTENT", blogc_content_parse(tmp, &end_excerpt));
- if (end_excerpt != 0)
- b_trie_insert(rv, "EXCERPT",
- b_strndup(b_trie_lookup(rv, "CONTENT"), end_excerpt));
- else
- b_trie_insert(rv, "EXCERPT",
- b_strdup(b_trie_lookup(rv, "CONTENT")));
+ content = blogc_content_parse(tmp, &end_excerpt);
+ b_trie_insert(rv, "CONTENT", content);
+ b_trie_insert(rv, "EXCERPT", end_excerpt == 0 ?
+ b_strdup(content) : b_strndup(content, end_excerpt));
}
break;
}