Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
c293e73e
Kaydet (Commit)
c293e73e
authored
Eki 16, 2013
tarafından
Matúš Kukan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
FastAttributeList: avoid OStrings in attribute list; just use char buffer
Change-Id: I4879563fae3b85c68bbd1c4b260f9833848f4bda
üst
9ae70150
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
25 deletions
+60
-25
fastattribs.hxx
include/sax/fastattribs.hxx
+14
-6
fastparser.cxx
sax/source/fastparser/fastparser.cxx
+4
-4
fastattribs.cxx
sax/source/tools/fastattribs.cxx
+42
-15
No files found.
include/sax/fastattribs.hxx
Dosyayı görüntüle @
c293e73e
...
...
@@ -40,9 +40,9 @@ struct UnknownAttribute
OString
maName
;
OString
maValue
;
UnknownAttribute
(
const
OUString
&
rNamespaceURL
,
const
OString
&
rName
,
const
OString
&
r
Value
);
UnknownAttribute
(
const
OUString
&
rNamespaceURL
,
const
OString
&
rName
,
const
sal_Char
*
p
Value
);
UnknownAttribute
(
const
OString
&
rName
,
const
OString
&
r
Value
);
UnknownAttribute
(
const
OString
&
rName
,
const
sal_Char
*
p
Value
);
void
FillAttribute
(
::
com
::
sun
::
star
::
xml
::
Attribute
*
pAttrib
)
const
;
};
...
...
@@ -56,9 +56,10 @@ public:
virtual
~
FastAttributeList
();
void
clear
();
void
add
(
sal_Int32
nToken
,
const
sal_Char
*
pValue
,
size_t
nValueLength
=
0
);
void
add
(
sal_Int32
nToken
,
const
OString
&
rValue
);
void
addUnknown
(
const
OUString
&
rNamespaceURL
,
const
OString
&
rName
,
const
OString
&
r
Value
);
void
addUnknown
(
const
OString
&
rName
,
const
OString
&
r
Value
);
void
addUnknown
(
const
OUString
&
rNamespaceURL
,
const
OString
&
rName
,
const
sal_Char
*
p
Value
);
void
addUnknown
(
const
OString
&
rName
,
const
sal_Char
*
p
Value
);
// XFastAttributeList
virtual
::
sal_Bool
SAL_CALL
hasAttribute
(
::
sal_Int32
Token
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
...
...
@@ -70,11 +71,18 @@ public:
virtual
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
xml
::
FastAttribute
>
SAL_CALL
getFastAttributes
()
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
private
:
inline
sal_Int32
AttributeValueLength
(
sal_Int32
i
);
private
:
sal_Char
*
mpChunk
;
///< buffer to store all attribute values - null terminated strings
sal_Int32
mnChunkLength
;
///< size of allocated memory for mpChunk
// maAttributeValues stores pointers, relative to mpChunk, for each attribute value string
// length of the string is maAttributeValues[n+1] - maAttributeValues[n] - 1
// maAttributeValues[0] == 0
std
::
vector
<
sal_Int32
>
maAttributeValues
;
std
::
vector
<
sal_Int32
>
maAttributeTokens
;
std
::
vector
<
OString
>
maAttributeValues
;
UnknownAttributeList
maUnknownAttributes
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XFastTokenHandler
>
mxTokenHandler
;
};
}
...
...
sax/source/fastparser/fastparser.cxx
Dosyayı görüntüle @
c293e73e
...
...
@@ -793,10 +793,10 @@ void FastSaxParser::callbackStartElement( const XML_Char* pwName, const XML_Char
{
sal_Int32
nAttributeToken
=
GetTokenWithPrefix
(
pPrefix
,
nPrefixLen
,
pName
,
nNameLen
);
if
(
nAttributeToken
!=
FastToken
::
DONTKNOW
)
rEntity
.
mxAttributes
->
add
(
nAttributeToken
,
OString
(
awAttributes
[
i
+
1
])
);
rEntity
.
mxAttributes
->
add
(
nAttributeToken
,
awAttributes
[
i
+
1
]
);
else
rEntity
.
mxAttributes
->
addUnknown
(
GetNamespaceURL
(
pPrefix
,
nPrefixLen
),
OString
(
pName
,
nNameLen
),
OString
(
awAttributes
[
i
+
1
])
);
OString
(
pName
,
nNameLen
),
awAttributes
[
i
+
1
]
);
}
}
else
...
...
@@ -805,9 +805,9 @@ void FastSaxParser::callbackStartElement( const XML_Char* pwName, const XML_Char
{
sal_Int32
nAttributeToken
=
GetToken
(
pName
,
nNameLen
);
if
(
nAttributeToken
!=
FastToken
::
DONTKNOW
)
rEntity
.
mxAttributes
->
add
(
nAttributeToken
,
OString
(
awAttributes
[
i
+
1
])
);
rEntity
.
mxAttributes
->
add
(
nAttributeToken
,
awAttributes
[
i
+
1
]
);
else
rEntity
.
mxAttributes
->
addUnknown
(
OString
(
pName
,
nNameLen
),
OString
(
awAttributes
[
i
+
1
])
);
rEntity
.
mxAttributes
->
addUnknown
(
OString
(
pName
,
nNameLen
),
awAttributes
[
i
+
1
]
);
}
}
}
...
...
sax/source/tools/fastattribs.cxx
Dosyayı görüntüle @
c293e73e
...
...
@@ -27,13 +27,13 @@ using namespace ::com::sun::star::xml::sax;
namespace
sax_fastparser
{
UnknownAttribute
::
UnknownAttribute
(
const
OUString
&
rNamespaceURL
,
const
OString
&
rName
,
const
OString
&
r
Value
)
:
maNamespaceURL
(
rNamespaceURL
),
maName
(
rName
),
maValue
(
r
Value
)
UnknownAttribute
::
UnknownAttribute
(
const
OUString
&
rNamespaceURL
,
const
OString
&
rName
,
const
sal_Char
*
p
Value
)
:
maNamespaceURL
(
rNamespaceURL
),
maName
(
rName
),
maValue
(
p
Value
)
{
}
UnknownAttribute
::
UnknownAttribute
(
const
OString
&
rName
,
const
OString
&
r
Value
)
:
maName
(
rName
),
maValue
(
r
Value
)
UnknownAttribute
::
UnknownAttribute
(
const
OString
&
rName
,
const
sal_Char
*
p
Value
)
:
maName
(
rName
),
maValue
(
p
Value
)
{
}
...
...
@@ -50,33 +50,54 @@ void UnknownAttribute::FillAttribute( Attribute* pAttrib ) const
FastAttributeList
::
FastAttributeList
(
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XFastTokenHandler
>&
xTokenHandler
)
:
mxTokenHandler
(
xTokenHandler
)
{
// random initial size of buffer to store attribute values
mnChunkLength
=
58
;
mpChunk
=
(
sal_Char
*
)
malloc
(
mnChunkLength
);
maAttributeValues
.
push_back
(
0
);
}
FastAttributeList
::~
FastAttributeList
()
{
free
(
mpChunk
);
}
void
FastAttributeList
::
clear
()
{
maAttributeTokens
.
clear
();
maAttributeValues
.
clear
();
maAttributeValues
.
push_back
(
0
);
maUnknownAttributes
.
clear
();
}
void
FastAttributeList
::
add
(
sal_Int32
nToken
,
const
OString
&
rValue
)
void
FastAttributeList
::
add
(
sal_Int32
nToken
,
const
sal_Char
*
pValue
,
size_t
nValueLength
)
{
maAttributeTokens
.
push_back
(
nToken
);
maAttributeValues
.
push_back
(
rValue
);
if
(
nValueLength
==
0
)
nValueLength
=
strlen
(
pValue
);
sal_Int32
nWritePosition
=
maAttributeValues
.
back
();
maAttributeValues
.
push_back
(
maAttributeValues
.
back
()
+
nValueLength
+
1
);
if
(
maAttributeValues
.
back
()
>
mnChunkLength
)
{
mnChunkLength
=
maAttributeValues
.
back
();
mpChunk
=
(
sal_Char
*
)
realloc
(
mpChunk
,
mnChunkLength
);
}
strncpy
(
mpChunk
+
nWritePosition
,
pValue
,
nValueLength
);
mpChunk
[
nWritePosition
+
nValueLength
]
=
'\0'
;
}
void
FastAttributeList
::
add
(
sal_Int32
nToken
,
const
OString
&
rValue
)
{
add
(
nToken
,
rValue
.
getStr
(),
rValue
.
getLength
()
);
}
void
FastAttributeList
::
addUnknown
(
const
OUString
&
rNamespaceURL
,
const
OString
&
rName
,
const
OString
&
r
Value
)
void
FastAttributeList
::
addUnknown
(
const
OUString
&
rNamespaceURL
,
const
OString
&
rName
,
const
sal_Char
*
p
Value
)
{
maUnknownAttributes
.
push_back
(
UnknownAttribute
(
rNamespaceURL
,
rName
,
r
Value
)
);
maUnknownAttributes
.
push_back
(
UnknownAttribute
(
rNamespaceURL
,
rName
,
p
Value
)
);
}
void
FastAttributeList
::
addUnknown
(
const
OString
&
rName
,
const
OString
&
r
Value
)
void
FastAttributeList
::
addUnknown
(
const
OString
&
rName
,
const
sal_Char
*
p
Value
)
{
maUnknownAttributes
.
push_back
(
UnknownAttribute
(
rName
,
r
Value
)
);
maUnknownAttributes
.
push_back
(
UnknownAttribute
(
rName
,
p
Value
)
);
}
// XFastAttributeList
...
...
@@ -94,7 +115,7 @@ sal_Int32 FastAttributeList::getValueToken( ::sal_Int32 Token ) throw (SAXExcept
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
if
(
maAttributeTokens
[
i
]
==
Token
)
{
Sequence
<
sal_Int8
>
aSeq
(
(
sal_Int8
*
)
m
aAttributeValues
[
i
].
getStr
(),
maAttributeValues
[
i
].
getLength
(
)
);
Sequence
<
sal_Int8
>
aSeq
(
(
sal_Int8
*
)
m
pChunk
+
maAttributeValues
[
i
],
AttributeValueLength
(
i
)
);
return
mxTokenHandler
->
getTokenFromUTF8
(
aSeq
);
}
...
...
@@ -106,7 +127,7 @@ sal_Int32 FastAttributeList::getOptionalValueToken( ::sal_Int32 Token, ::sal_Int
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
if
(
maAttributeTokens
[
i
]
==
Token
)
{
Sequence
<
sal_Int8
>
aSeq
(
(
sal_Int8
*
)
m
aAttributeValues
[
i
].
getStr
(),
maAttributeValues
[
i
].
getLength
(
)
);
Sequence
<
sal_Int8
>
aSeq
(
(
sal_Int8
*
)
m
pChunk
+
maAttributeValues
[
i
],
AttributeValueLength
(
i
)
);
return
mxTokenHandler
->
getTokenFromUTF8
(
aSeq
);
}
...
...
@@ -117,7 +138,7 @@ OUString FastAttributeList::getValue( ::sal_Int32 Token ) throw (SAXException, R
{
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
if
(
maAttributeTokens
[
i
]
==
Token
)
return
O
StringToOUString
(
maAttributeValues
[
i
]
,
RTL_TEXTENCODING_UTF8
);
return
O
UString
(
mpChunk
+
maAttributeValues
[
i
],
AttributeValueLength
(
i
)
,
RTL_TEXTENCODING_UTF8
);
throw
SAXException
();
}
...
...
@@ -126,7 +147,7 @@ OUString FastAttributeList::getOptionalValue( ::sal_Int32 Token ) throw (Runtime
{
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
if
(
maAttributeTokens
[
i
]
==
Token
)
return
O
StringToOUString
(
maAttributeValues
[
i
]
,
RTL_TEXTENCODING_UTF8
);
return
O
UString
(
mpChunk
+
maAttributeValues
[
i
],
AttributeValueLength
(
i
)
,
RTL_TEXTENCODING_UTF8
);
return
OUString
();
}
...
...
@@ -145,12 +166,18 @@ Sequence< FastAttribute > FastAttributeList::getFastAttributes( ) throw (Runtim
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
{
pAttr
->
Token
=
maAttributeTokens
[
i
];
pAttr
->
Value
=
O
StringToOUString
(
maAttributeValues
[
i
]
,
RTL_TEXTENCODING_UTF8
);
pAttr
->
Value
=
O
UString
(
mpChunk
+
maAttributeValues
[
i
],
AttributeValueLength
(
i
)
,
RTL_TEXTENCODING_UTF8
);
pAttr
++
;
}
return
aSeq
;
}
sal_Int32
FastAttributeList
::
AttributeValueLength
(
sal_Int32
i
)
{
// Pointers to null terminated strings
return
maAttributeValues
[
i
+
1
]
-
maAttributeValues
[
i
]
-
1
;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment