Re: [xml] Minor improvement possible

2017-08-28 Thread Daniel Veillard
  Hi Bruce,

 indeed a minor improvement, but that sounds absolutely right, those
data tables are never updated,

  Applied and pushed:

https://git.gnome.org/browse/libxml2/commit/?id=8f57103793e1e1b1be478f1feb607d19d725d048

  thanks a lot,

Daniel


On Thu, Jan 05, 2017 at 03:00:20PM -0800, Bruce Dawson via xml wrote:
> The constant array xmlUnicodeBlocks is not marked as 'const' so it ends up
> in the read/write data segment instead of the read-only data segment, which
> can lead to it becoming per-process private data instead of image-backed
> shared data.
> 
> A patch file (made in the context of Chrome, but it should be applicable to
> libxml2) is attached.
> 
> -- 
> Bruce Dawson

> commit eafa8bbee03e8ebba366be1fb8d5b1596a989a0a
> Author: Bruce Dawson 
> Date:   Thu Jan 5 11:25:58 2017 -0800
> 
> Add const in five places to move 1 KiB to .rdata
> 
> xmlUnicodeBlocks is logically const but was not marked as such. This
> fixes that, thus moving it to the read-only data segment.
> 
> BUG=677351
> 
> diff --git a/third_party/libxml/src/genUnicode.py 
> b/third_party/libxml/src/genUnicode.py
> index 56e4e9b..4487eeb 100755
> --- a/third_party/libxml/src/genUnicode.py
> +++ b/third_party/libxml/src/genUnicode.py
> @@ -267,14 +267,14 @@ typedef struct {
>  } xmlUnicodeRange;
>  
>  typedef struct {
> -xmlUnicodeRange *table;
> +const xmlUnicodeRange *table;
>  int  numentries;
>  } xmlUnicodeNameTable;
>  
>  
>  static xmlIntFunc *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char 
> *tname);
>  
> -static xmlUnicodeRange xmlUnicodeBlocks[] = {
> +static const xmlUnicodeRange xmlUnicodeBlocks[] = {
>  """ % (webpage, date, sources));
>  
>  flag = 0
> diff --git a/third_party/libxml/src/xmlunicode.c 
> b/third_party/libxml/src/xmlunicode.c
> index ce6e9a4..6d0a96a 100644
> --- a/third_party/libxml/src/xmlunicode.c
> +++ b/third_party/libxml/src/xmlunicode.c
> @@ -29,14 +29,14 @@ typedef struct {
>  } xmlUnicodeRange;
>  
>  typedef struct {
> -xmlUnicodeRange *table;
> +const xmlUnicodeRange *table;
>  int  numentries;
>  } xmlUnicodeNameTable;
>  
>  
>  static xmlIntFunc *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char 
> *tname);
>  
> -static xmlUnicodeRange xmlUnicodeBlocks[] = {
> +static const xmlUnicodeRange xmlUnicodeBlocks[] = {
>{"AegeanNumbers", xmlUCSIsAegeanNumbers},
>{"AlphabeticPresentationForms", xmlUCSIsAlphabeticPresentationForms},
>{"Arabic", xmlUCSIsArabic},
> @@ -945,7 +945,7 @@ static xmlUnicodeNameTable xmlUnicodeCatTbl = 
> {xmlUnicodeCats, 36};
>  static xmlIntFunc
>  *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char *tname) {
>  int low, high, mid, cmp;
> -xmlUnicodeRange *sptr;
> +const xmlUnicodeRange *sptr;
>  
>  if ((tptr == NULL) || (tname == NULL)) return(NULL);
>  

> ___
> xml mailing list, project page  http://xmlsoft.org/
> xml@gnome.org
> https://mail.gnome.org/mailman/listinfo/xml


-- 
Daniel Veillard  | Red Hat Developers Tools http://developer.redhat.com/
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] Minor improvement possible

2017-01-10 Thread Bruce Dawson via xml
I blogged about the importance of adding const in order to get best results
here:
https://randomascii.wordpress.com/2017/01/08/add-a-const-here-delete-a-const-there/

Some of the post talks about a VC++ compiler bug - ignore that.

Note that having constant data in the read-only data segment is a best
practice even for single-processing. It's not a huge advantage, but it is
strictly better than having logically-const globals in the read/write data
segment.

On Thu, Jan 5, 2017 at 3:00 PM, Bruce Dawson  wrote:

> The constant array xmlUnicodeBlocks is not marked as 'const' so it ends up
> in the read/write data segment instead of the read-only data segment, which
> can lead to it becoming per-process private data instead of image-backed
> shared data.
>
> A patch file (made in the context of Chrome, but it should be applicable
> to libxml2) is attached.
>
> --
> Bruce Dawson
>



-- 
Bruce Dawson
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


[xml] Minor improvement possible

2017-01-05 Thread Bruce Dawson via xml
The constant array xmlUnicodeBlocks is not marked as 'const' so it ends up
in the read/write data segment instead of the read-only data segment, which
can lead to it becoming per-process private data instead of image-backed
shared data.

A patch file (made in the context of Chrome, but it should be applicable to
libxml2) is attached.

-- 
Bruce Dawson
commit eafa8bbee03e8ebba366be1fb8d5b1596a989a0a
Author: Bruce Dawson 
Date:   Thu Jan 5 11:25:58 2017 -0800

Add const in five places to move 1 KiB to .rdata

xmlUnicodeBlocks is logically const but was not marked as such. This
fixes that, thus moving it to the read-only data segment.

BUG=677351

diff --git a/third_party/libxml/src/genUnicode.py 
b/third_party/libxml/src/genUnicode.py
index 56e4e9b..4487eeb 100755
--- a/third_party/libxml/src/genUnicode.py
+++ b/third_party/libxml/src/genUnicode.py
@@ -267,14 +267,14 @@ typedef struct {
 } xmlUnicodeRange;
 
 typedef struct {
-xmlUnicodeRange *table;
+const xmlUnicodeRange *table;
 intnumentries;
 } xmlUnicodeNameTable;
 
 
 static xmlIntFunc *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char 
*tname);
 
-static xmlUnicodeRange xmlUnicodeBlocks[] = {
+static const xmlUnicodeRange xmlUnicodeBlocks[] = {
 """ % (webpage, date, sources));
 
 flag = 0
diff --git a/third_party/libxml/src/xmlunicode.c 
b/third_party/libxml/src/xmlunicode.c
index ce6e9a4..6d0a96a 100644
--- a/third_party/libxml/src/xmlunicode.c
+++ b/third_party/libxml/src/xmlunicode.c
@@ -29,14 +29,14 @@ typedef struct {
 } xmlUnicodeRange;
 
 typedef struct {
-xmlUnicodeRange *table;
+const xmlUnicodeRange *table;
 intnumentries;
 } xmlUnicodeNameTable;
 
 
 static xmlIntFunc *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char 
*tname);
 
-static xmlUnicodeRange xmlUnicodeBlocks[] = {
+static const xmlUnicodeRange xmlUnicodeBlocks[] = {
   {"AegeanNumbers", xmlUCSIsAegeanNumbers},
   {"AlphabeticPresentationForms", xmlUCSIsAlphabeticPresentationForms},
   {"Arabic", xmlUCSIsArabic},
@@ -945,7 +945,7 @@ static xmlUnicodeNameTable xmlUnicodeCatTbl = 
{xmlUnicodeCats, 36};
 static xmlIntFunc
 *xmlUnicodeLookup(xmlUnicodeNameTable *tptr, const char *tname) {
 int low, high, mid, cmp;
-xmlUnicodeRange *sptr;
+const xmlUnicodeRange *sptr;
 
 if ((tptr == NULL) || (tname == NULL)) return(NULL);
 
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml