From 01d8d19b1219d8d917050b2896002dddebb59431 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 1 Dec 2008 16:46:45 +0000 Subject: The advantage of interning strings is that you don't have to store their length everywhere. Purge the length part from the encoding of a string in the bytecode. Fix bytecode dump code to cope with this. svn path=/trunk/libcss/; revision=5864 --- src/bytecode/dump.c | 13 ++++++------- src/parse/properties.c | 32 ++++++++++++-------------------- 2 files changed, 18 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/bytecode/dump.c b/src/bytecode/dump.c index 05213ee..0cf54c8 100644 --- a/src/bytecode/dump.c +++ b/src/bytecode/dump.c @@ -166,14 +166,13 @@ void css_bytecode_dump(void *bytecode, uint32_t length, FILE *fp) break; case BACKGROUND_IMAGE_URI: { - uint8_t *ptr = - *((uint8_t **) bytecode); + parserutils_hash_entry *ptr = + *((parserutils_hash_entry **) + bytecode); ADVANCE(sizeof(ptr)); - size_t len = - *((size_t *) bytecode); - ADVANCE(sizeof(len)); - fprintf(fp, "url('%.*s')", (int) len, - (char *) ptr); + fprintf(fp, "url('%.*s')", + (int) ptr->len, + (char *) ptr->data); } break; } diff --git a/src/parse/properties.c b/src/parse/properties.c index e6a285d..94cf4fa 100644 --- a/src/parse/properties.c +++ b/src/parse/properties.c @@ -658,7 +658,7 @@ css_error parse_background_image(css_language *c, required_size = sizeof(opv); if ((flags & FLAG_INHERIT) == false && value == BACKGROUND_IMAGE_URI) - required_size += sizeof(uint8_t *) + sizeof(size_t); + required_size += sizeof(parserutils_hash_entry *); /* Allocate result */ error = css_stylesheet_style_create(c->sheet, required_size, result); @@ -669,10 +669,8 @@ css_error parse_background_image(css_language *c, memcpy((*result)->bytecode, &opv, sizeof(opv)); if ((flags & FLAG_INHERIT) == false && value == BACKGROUND_IMAGE_URI) { memcpy((uint8_t *) (*result)->bytecode + sizeof(opv), - &token->data.data, sizeof(uint8_t *)); - memcpy((uint8_t *) (*result)->bytecode + sizeof(opv) + - sizeof(uint8_t *), - &token->data.len, sizeof(size_t)); + &token->idata, + sizeof(parserutils_hash_entry *)); } return CSS_OK; @@ -1166,7 +1164,7 @@ css_error parse_cue_after(css_language *c, required_size = sizeof(opv); if ((flags & FLAG_INHERIT) == false && value == CUE_AFTER_URI) - required_size += sizeof(uint8_t *) + sizeof(size_t); + required_size += sizeof(parserutils_hash_entry *); /* Allocate result */ error = css_stylesheet_style_create(c->sheet, required_size, result); @@ -1177,10 +1175,8 @@ css_error parse_cue_after(css_language *c, memcpy((*result)->bytecode, &opv, sizeof(opv)); if ((flags & FLAG_INHERIT) == false && value == CUE_AFTER_URI) { memcpy((uint8_t *) (*result)->bytecode + sizeof(opv), - &token->data.data, sizeof(uint8_t *)); - memcpy((uint8_t *) (*result)->bytecode + sizeof(opv) + - sizeof(uint8_t *), - &token->data.len, sizeof(size_t)); + &token->idata, + sizeof(parserutils_hash_entry *)); } return CSS_OK; @@ -1222,7 +1218,7 @@ css_error parse_cue_before(css_language *c, required_size = sizeof(opv); if ((flags & FLAG_INHERIT) == false && value == CUE_BEFORE_URI) - required_size += sizeof(uint8_t *) + sizeof(size_t); + required_size += sizeof(parserutils_hash_entry *); /* Allocate result */ error = css_stylesheet_style_create(c->sheet, required_size, result); @@ -1233,10 +1229,8 @@ css_error parse_cue_before(css_language *c, memcpy((*result)->bytecode, &opv, sizeof(opv)); if ((flags & FLAG_INHERIT) == false && value == CUE_BEFORE_URI) { memcpy((uint8_t *) (*result)->bytecode + sizeof(opv), - &token->data.data, sizeof(uint8_t *)); - memcpy((uint8_t *) (*result)->bytecode + sizeof(opv) + - sizeof(uint8_t *), - &token->data.len, sizeof(size_t)); + &token->idata, + sizeof(parserutils_hash_entry *)); } return CSS_OK; @@ -2101,7 +2095,7 @@ css_error parse_list_style_image(css_language *c, required_size = sizeof(opv); if ((flags & FLAG_INHERIT) == false && value == LIST_STYLE_IMAGE_URI) - required_size += sizeof(uint8_t *) + sizeof(size_t); + required_size += sizeof(parserutils_hash_entry *); /* Allocate result */ error = css_stylesheet_style_create(c->sheet, required_size, result); @@ -2112,10 +2106,8 @@ css_error parse_list_style_image(css_language *c, memcpy((*result)->bytecode, &opv, sizeof(opv)); if ((flags & FLAG_INHERIT) == false && value == LIST_STYLE_IMAGE_URI) { memcpy((uint8_t *) (*result)->bytecode + sizeof(opv), - &token->data.data, sizeof(uint8_t *)); - memcpy((uint8_t *) (*result)->bytecode + sizeof(opv) + - sizeof(uint8_t *), - &token->data.len, sizeof(size_t)); + &token->idata, + sizeof(parserutils_hash_entry *)); } return CSS_OK; -- cgit v1.2.3