mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-23 02:50:08 +03:00
globals: Remove unused globals from thread storage
Setting these deprecated globals hasn't had an effect for a long time. Make them constants. This reduces the size of per-thread storage from ~700 to ~250 bytes.
This commit is contained in:
parent
be558647c1
commit
c011e7605d
15
HTMLparser.c
15
HTMLparser.c
@ -4844,10 +4844,12 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
|
||||
}
|
||||
|
||||
/*
|
||||
* SAX: beginning of the document processing.
|
||||
* Document locator is unused. Only for backward compatibility.
|
||||
*/
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
|
||||
xmlSAXLocator copy = xmlDefaultSAXLocator;
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, ©);
|
||||
}
|
||||
|
||||
xmlDetectEncoding(ctxt);
|
||||
|
||||
@ -5435,9 +5437,10 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||
SKIP_BLANKS;
|
||||
avail = in->end - in->cur;
|
||||
}
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData,
|
||||
&xmlDefaultSAXLocator);
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
|
||||
xmlSAXLocator copy = xmlDefaultSAXLocator;
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, ©);
|
||||
}
|
||||
if ((ctxt->sax) && (ctxt->sax->startDocument) &&
|
||||
(!ctxt->disableSAX))
|
||||
ctxt->sax->startDocument(ctxt->userData);
|
||||
|
@ -63,7 +63,6 @@ ignored_words = {
|
||||
"XML_DEPRECATED": (0, "macro keyword"),
|
||||
"XML_GLOBALS_ALLOC": (0, "macro keyword"),
|
||||
"XML_GLOBALS_ERROR": (0, "macro keyword"),
|
||||
"XML_GLOBALS_HTML": (0, "macro keyword"),
|
||||
"XML_GLOBALS_IO": (0, "macro keyword"),
|
||||
"XML_GLOBALS_PARSER": (0, "macro keyword"),
|
||||
"XML_GLOBALS_SAVE": (0, "macro keyword"),
|
||||
|
47
globals.c
47
globals.c
@ -20,7 +20,6 @@
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/threads.h>
|
||||
#include <libxml/tree.h>
|
||||
@ -79,7 +78,6 @@ struct _xmlGlobalState {
|
||||
#define XML_OP XML_DECLARE_MEMBER
|
||||
XML_GLOBALS_ALLOC
|
||||
XML_GLOBALS_ERROR
|
||||
XML_GLOBALS_HTML
|
||||
XML_GLOBALS_IO
|
||||
XML_GLOBALS_PARSER
|
||||
XML_GLOBALS_SAVE
|
||||
@ -265,7 +263,7 @@ static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
|
||||
*
|
||||
* Global setting, DEPRECATED.
|
||||
*/
|
||||
int oldXMLWDcompatibility = 0; /* DEPRECATED */
|
||||
const int oldXMLWDcompatibility = 0; /* DEPRECATED */
|
||||
/**
|
||||
* xmlParserDebugEntities:
|
||||
*
|
||||
@ -461,7 +459,7 @@ static int xmlSaveNoEmptyTagsThrDef = 0;
|
||||
*
|
||||
* Default SAX version1 handler for XML, builds the DOM tree
|
||||
*/
|
||||
xmlSAXHandlerV1 xmlDefaultSAXHandler = {
|
||||
const xmlSAXHandlerV1 xmlDefaultSAXHandler = {
|
||||
xmlSAX2InternalSubset,
|
||||
xmlSAX2IsStandalone,
|
||||
xmlSAX2HasInternalSubset,
|
||||
@ -501,7 +499,7 @@ xmlSAXHandlerV1 xmlDefaultSAXHandler = {
|
||||
* The default SAX Locator
|
||||
* { getPublicId, getSystemId, getLineNumber, getColumnNumber}
|
||||
*/
|
||||
xmlSAXLocator xmlDefaultSAXLocator = {
|
||||
const xmlSAXLocator xmlDefaultSAXLocator = {
|
||||
xmlSAX2GetPublicId,
|
||||
xmlSAX2GetSystemId,
|
||||
xmlSAX2GetLineNumber,
|
||||
@ -517,7 +515,7 @@ xmlSAXLocator xmlDefaultSAXLocator = {
|
||||
*
|
||||
* Default old SAX v1 handler for HTML, builds the DOM tree
|
||||
*/
|
||||
xmlSAXHandlerV1 htmlDefaultSAXHandler = {
|
||||
const xmlSAXHandlerV1 htmlDefaultSAXHandler = {
|
||||
xmlSAX2InternalSubset,
|
||||
NULL,
|
||||
NULL,
|
||||
@ -757,20 +755,8 @@ static void
|
||||
xmlInitGlobalState(xmlGlobalStatePtr gs) {
|
||||
xmlMutexLock(&xmlThrDefMutex);
|
||||
|
||||
#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
|
||||
inithtmlDefaultSAXHandler(&gs->gs_htmlDefaultSAXHandler);
|
||||
#endif
|
||||
|
||||
gs->gs_oldXMLWDcompatibility = 0;
|
||||
gs->gs_xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
|
||||
gs->gs_xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
|
||||
#if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
|
||||
initxmlDefaultSAXHandler(&gs->gs_xmlDefaultSAXHandler, 1);
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
gs->gs_xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
|
||||
gs->gs_xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
|
||||
gs->gs_xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
|
||||
gs->gs_xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
|
||||
gs->gs_xmlDoValidityCheckingDefaultValue =
|
||||
xmlDoValidityCheckingDefaultValueThrDef;
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
@ -905,7 +891,6 @@ xmlGetThreadLocalStorage(int allowFailure) {
|
||||
#define XML_OP XML_DEFINE_GLOBAL_WRAPPER
|
||||
XML_GLOBALS_ALLOC
|
||||
XML_GLOBALS_ERROR
|
||||
XML_GLOBALS_HTML
|
||||
XML_GLOBALS_IO
|
||||
XML_GLOBALS_PARSER
|
||||
XML_GLOBALS_SAVE
|
||||
@ -919,6 +904,30 @@ __xmlParserVersion(void) {
|
||||
return &xmlParserVersion;
|
||||
}
|
||||
|
||||
const int *
|
||||
__oldXMLWDcompatibility(void) {
|
||||
return &oldXMLWDcompatibility;
|
||||
}
|
||||
|
||||
const xmlSAXLocator *
|
||||
__xmlDefaultSAXLocator(void) {
|
||||
return &xmlDefaultSAXLocator;
|
||||
}
|
||||
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
const xmlSAXHandlerV1 *
|
||||
__xmlDefaultSAXHandler(void) {
|
||||
return &xmlDefaultSAXHandler;
|
||||
}
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
const xmlSAXHandlerV1 *
|
||||
__htmlDefaultSAXHandler(void) {
|
||||
return &htmlDefaultSAXHandler;
|
||||
}
|
||||
#endif /* LIBXML_HTML_ENABLED */
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
|
||||
#endif /* LIBXML_THREAD_ENABLED */
|
||||
|
||||
/**
|
||||
|
@ -80,22 +80,17 @@ struct _htmlEntityDesc {
|
||||
const char *desc; /* the description */
|
||||
};
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
#define XML_GLOBALS_HTML \
|
||||
XML_OP(htmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
|
||||
#else
|
||||
#define XML_GLOBALS_HTML
|
||||
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const xmlSAXHandlerV1 htmlDefaultSAXHandler;
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN const xmlSAXHandlerV1 *__htmlDefaultSAXHandler(void);
|
||||
#endif
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_HTML
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define htmlDefaultSAXHandler XML_GLOBAL_MACRO(htmlDefaultSAXHandler)
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
|
||||
/*
|
||||
* There is only few public functions.
|
||||
@ -333,11 +328,5 @@ XMLPUBFUN htmlStatus htmlNodeStatus(htmlNodePtr, int) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* LIBXML_HTML_ENABLED */
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_HTML
|
||||
/** DOC_ENABLE */
|
||||
|
||||
#endif /* LIBXML_HTML_ENABLED */
|
||||
#endif /* __HTML_PARSER_H__ */
|
||||
|
@ -841,15 +841,30 @@ typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
|
||||
*/
|
||||
|
||||
XMLPUBVAR const char *const xmlParserVersion;
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const int oldXMLWDcompatibility;
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const xmlSAXLocator xmlDefaultSAXLocator;
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const xmlSAXHandlerV1 xmlDefaultSAXHandler;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
/* backward compatibility */
|
||||
XMLPUBFUN const char *const *__xmlParserVersion(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN const int *__oldXMLWDcompatibility(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN const xmlSAXLocator *__xmlDefaultSAXLocator(void);
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN const xmlSAXHandlerV1 *__xmlDefaultSAXHandler(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_PARSER_CORE \
|
||||
XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
|
||||
#define XML_GLOBALS_PARSER \
|
||||
XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
|
||||
@ -859,17 +874,6 @@ XMLPUBFUN const char *const *__xmlParserVersion(void);
|
||||
XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
|
||||
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
#define XML_GLOBALS_PARSER_SAX1 \
|
||||
XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
|
||||
#else
|
||||
#define XML_GLOBALS_PARSER_SAX1
|
||||
#endif
|
||||
|
||||
#define XML_GLOBALS_PARSER \
|
||||
XML_GLOBALS_PARSER_CORE \
|
||||
XML_GLOBALS_PARSER_SAX1
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_PARSER
|
||||
#undef XML_OP
|
||||
|
24
parser.c
24
parser.c
@ -11022,10 +11022,13 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
|
||||
xmlDetectSAX2(ctxt);
|
||||
|
||||
/*
|
||||
* SAX: beginning of the document processing.
|
||||
* Document locator is unused. Only for backward compatibility.
|
||||
*/
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
|
||||
xmlSAXLocator copy = xmlDefaultSAXLocator;
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, ©);
|
||||
}
|
||||
|
||||
if (ctxt->instate == XML_PARSER_EOF)
|
||||
return(-1);
|
||||
|
||||
@ -11185,10 +11188,12 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
|
||||
xmlDetectSAX2(ctxt);
|
||||
|
||||
/*
|
||||
* SAX: beginning of the document processing.
|
||||
* Document locator is unused. Only for backward compatibility.
|
||||
*/
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
|
||||
xmlSAXLocator copy = xmlDefaultSAXLocator;
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, ©);
|
||||
}
|
||||
|
||||
xmlDetectEncoding(ctxt);
|
||||
|
||||
@ -11673,9 +11678,10 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData,
|
||||
&xmlDefaultSAXLocator);
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
|
||||
xmlSAXLocator copy = xmlDefaultSAXLocator;
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, ©);
|
||||
}
|
||||
if ((ctxt->sax) && (ctxt->sax->startDocument) &&
|
||||
(!ctxt->disableSAX))
|
||||
ctxt->sax->startDocument(ctxt->userData);
|
||||
|
Loading…
x
Reference in New Issue
Block a user