summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-12-01 03:23:25 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-12-01 03:23:25 +0000
commit3a03e4be1a744d37c66ea97651ca082ee4eb39d4 (patch)
tree1413ab7738e519a88c4fe7cd9910f02a2339cbd1
parentdb917066e504364749a21a43b2fd8193db0322e8 (diff)
downloadlibcss-3a03e4be1a744d37c66ea97651ca082ee4eb39d4.tar.gz
libcss-3a03e4be1a744d37c66ea97651ca082ee4eb39d4.tar.bz2
Divorce css_string from whatever gets stored in lpu hashes.
Use pointers to parserutils_hash_entry directly in stylesheet datastructures. The upshot of this for allzengarden.css is: 5506 slots used (of 8192 => 67.211914%) Data: 8 full blocks: 32768 bytes 9 partial blocks: 35124 bytes (of 36864 => 95.279945%) Total: 69936 (4112) (32) Hash structures: 65584 i.e. a total string dictionary size of 135,520 bytes, which is some 74,056 bytes less than before. svn path=/trunk/libcss/; revision=5859
-rw-r--r--include/libcss/types.h8
-rw-r--r--src/parse/parse.c7
-rw-r--r--src/stylesheet.c10
-rw-r--r--src/stylesheet.h4
-rw-r--r--test/css21.c6
5 files changed, 19 insertions, 16 deletions
diff --git a/include/libcss/types.h b/include/libcss/types.h
index 8bda940..f095f1c 100644
--- a/include/libcss/types.h
+++ b/include/libcss/types.h
@@ -55,11 +55,11 @@ typedef enum css_origin {
/**
* String type
- *
- * \todo It might be better to define parserutils_string, and use that.
- * (where parserutils_string is identical to parserutils_hash_entry)
*/
-typedef parserutils_hash_entry css_string;
+typedef struct css_string {
+ size_t len;
+ uint8_t *data;
+} css_string;
typedef struct css_stylesheet css_stylesheet;
diff --git a/src/parse/parse.c b/src/parse/parse.c
index 54b37d8..ff8c813 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -639,7 +639,8 @@ css_error getToken(css_parser *parser, const css_token **token)
perror);
}
- t->lower.data = interned->data;
+ t->lower.data =
+ (uint8_t *) interned->data;
t->lower.len = interned->len;
}
}
@@ -650,14 +651,14 @@ css_error getToken(css_parser *parser, const css_token **token)
&interned);
if (t->lower.data == NULL) {
- t->lower.data = interned->data;
+ t->lower.data = (uint8_t *) interned->data;
t->lower.len = interned->len;
}
if (perror != PARSERUTILS_OK)
return css_error_from_parserutils_error(perror);
- t->data.data = interned->data;
+ t->data.data = (uint8_t *) interned->data;
t->data.len = interned->len;
} else {
t->data.data = t->lower.data = NULL;
diff --git a/src/stylesheet.c b/src/stylesheet.c
index b2e1c0e..f700a63 100644
--- a/src/stylesheet.c
+++ b/src/stylesheet.c
@@ -357,7 +357,7 @@ css_error css_stylesheet_selector_create(css_stylesheet *sheet,
css_selector_type type, const css_string *name,
const css_string *value, css_selector **selector)
{
- const css_string *iname, *ivalue;
+ const parserutils_hash_entry *iname, *ivalue;
css_selector *sel;
parserutils_error perror;
@@ -440,7 +440,7 @@ css_error css_stylesheet_selector_detail_create(css_stylesheet *sheet,
const css_string *value, css_selector_detail **detail)
{
parserutils_error perror;
- const css_string *iname, *ivalue;
+ const parserutils_hash_entry *iname, *ivalue;
css_selector_detail *det;
if (sheet == NULL || name == NULL || detail == NULL)
@@ -808,7 +808,8 @@ static void css_stylesheet_dump_selector(css_selector *selector, FILE *target,
size_t *size);
static void css_stylesheet_dump_selector_detail(css_selector_detail *detail,
FILE *target, size_t *size);
-static void css_stylesheet_dump_string(const css_string *string, FILE *target);
+static void css_stylesheet_dump_string(const parserutils_hash_entry *string,
+ FILE *target);
/**
* Dump a stylesheet
@@ -1025,7 +1026,8 @@ void css_stylesheet_dump_selector_detail(css_selector_detail *detail,
* \param string The string to dump
* \param target The file handle to output to
*/
-void css_stylesheet_dump_string(const css_string *string, FILE *target)
+void css_stylesheet_dump_string(const parserutils_hash_entry *string,
+ FILE *target)
{
fprintf(target, "%.*s", (int) string->len, string->data);
}
diff --git a/src/stylesheet.h b/src/stylesheet.h
index 1ab3939..487f408 100644
--- a/src/stylesheet.h
+++ b/src/stylesheet.h
@@ -48,8 +48,8 @@ typedef enum css_combinator {
} css_combinator;
typedef struct css_selector_detail {
- const css_string *name; /**< Interned name */
- const css_string *value; /**< Interned value, or NULL */
+ const parserutils_hash_entry *name; /**< Interned name */
+ const parserutils_hash_entry *value; /**< Interned value, or NULL */
uint32_t type : 4, /**< Type of selector */
comb : 2, /**< Type of combinator */
diff --git a/test/css21.c b/test/css21.c
index c8a0bd5..267beec 100644
--- a/test/css21.c
+++ b/test/css21.c
@@ -6,9 +6,9 @@
#include "testutils.h"
-#define ITERATIONS (10)
-#define DUMP_HASH (0)
-#define DUMP_CSS (0)
+#define ITERATIONS (1)
+#define DUMP_HASH (1)
+#define DUMP_CSS (1)
extern void parserutils_hash_dump(parserutils_hash *hash);