r5864 jmb - in /trunk/libcss: docs/Bytecode src/bytecode/dump.c src/parse/properties.c

netsurf at semichrome.net netsurf at semichrome.net
Mon Dec 1 16:46:45 GMT 2008


Author: jmb
Date: Mon Dec  1 10:46:45 2008
New Revision: 5864

URL: http://source.netsurf-browser.org?rev=5864&view=rev
Log:
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.

Modified:
    trunk/libcss/docs/Bytecode
    trunk/libcss/src/bytecode/dump.c
    trunk/libcss/src/parse/properties.c

Modified: trunk/libcss/docs/Bytecode
URL: http://source.netsurf-browser.org/trunk/libcss/docs/Bytecode?rev=5864&r1=5863&r2=5864&view=diff
==============================================================================
--- trunk/libcss/docs/Bytecode (original)
+++ trunk/libcss/docs/Bytecode Mon Dec  1 10:46:45 2008
@@ -27,9 +27,8 @@
 a fixed point value with 22 bits assigned to the integer part and 10 bits
 assigned to the fractional part.
 
-Strings are stored as <pointer,length> pairs, as per css_string.
-Pointer's width is the native width of a pointer on the platform.
-Length's width is the native width of a size_t on the platform.
+Strings are stored as a pointer to an interned string.
+The pointer's width is the native width of a pointer on the platform.
 
 CSS dimensions are stored as two 32bit values: <length, units>. 
 Length is a 32bit numeric value (as described above) and unit is as follows:

Modified: trunk/libcss/src/bytecode/dump.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/bytecode/dump.c?rev=5864&r1=5863&r2=5864&view=diff
==============================================================================
--- trunk/libcss/src/bytecode/dump.c (original)
+++ trunk/libcss/src/bytecode/dump.c Mon Dec  1 10:46:45 2008
@@ -166,14 +166,13 @@
 					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;
 				}

Modified: trunk/libcss/src/parse/properties.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/parse/properties.c?rev=5864&r1=5863&r2=5864&view=diff
==============================================================================
--- trunk/libcss/src/parse/properties.c (original)
+++ trunk/libcss/src/parse/properties.c Mon Dec  1 10:46:45 2008
@@ -658,7 +658,7 @@
 
 	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 @@
 	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 @@
 
 	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 @@
 	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 @@
 
 	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 @@
 	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 @@
 
 	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 @@
 	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;




More information about the netsurf-commits mailing list