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
fc25afaa
Kaydet (Commit)
fc25afaa
authored
Kas 19, 2013
tarafından
Michael Meeks
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fastparser: accelerate value tokenisation as well.
Change-Id: I99a39e91c684adb1fc92cdb466477cfa90104961
üst
7e77efe8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
37 deletions
+62
-37
fastattribs.hxx
include/sax/fastattribs.hxx
+13
-0
fastparser.cxx
sax/source/fastparser/fastparser.cxx
+1
-26
fastparser.hxx
sax/source/fastparser/fastparser.hxx
+1
-3
fastattribs.cxx
sax/source/tools/fastattribs.cxx
+47
-8
No files found.
include/sax/fastattribs.hxx
Dosyayı görüntüle @
fc25afaa
...
@@ -49,6 +49,18 @@ struct UnknownAttribute
...
@@ -49,6 +49,18 @@ struct UnknownAttribute
typedef
std
::
vector
<
UnknownAttribute
>
UnknownAttributeList
;
typedef
std
::
vector
<
UnknownAttribute
>
UnknownAttributeList
;
/// avoid constantly allocating and freeing sequences.
class
SAX_DLLPUBLIC
FastTokenLookup
{
static
const
int
mnUtf8BufferSize
=
128
;
::
css
::
uno
::
Sequence
<
sal_Int8
>
maUtf8Buffer
;
public
:
FastTokenLookup
();
sal_Int32
getTokenFromChars
(
const
::
css
::
uno
::
Reference
<
::
css
::
xml
::
sax
::
XFastTokenHandler
>
&
mxTokenHandler
,
const
char
*
pStr
,
size_t
nLength
=
0
);
};
class
SAX_DLLPUBLIC
FastAttributeList
:
public
::
cppu
::
WeakImplHelper1
<
::
com
::
sun
::
star
::
xml
::
sax
::
XFastAttributeList
>
class
SAX_DLLPUBLIC
FastAttributeList
:
public
::
cppu
::
WeakImplHelper1
<
::
com
::
sun
::
star
::
xml
::
sax
::
XFastAttributeList
>
{
{
public
:
public
:
...
@@ -83,6 +95,7 @@ private:
...
@@ -83,6 +95,7 @@ private:
std
::
vector
<
sal_Int32
>
maAttributeTokens
;
std
::
vector
<
sal_Int32
>
maAttributeTokens
;
UnknownAttributeList
maUnknownAttributes
;
UnknownAttributeList
maUnknownAttributes
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XFastTokenHandler
>
mxTokenHandler
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
sax
::
XFastTokenHandler
>
mxTokenHandler
;
FastTokenLookup
maTokenLookup
;
};
};
}
}
...
...
sax/source/fastparser/fastparser.cxx
Dosyayı görüntüle @
fc25afaa
...
@@ -348,7 +348,6 @@ Event& Entity::getEvent( CallbackType aType )
...
@@ -348,7 +348,6 @@ Event& Entity::getEvent( CallbackType aType )
FastSaxParser
::
FastSaxParser
()
FastSaxParser
::
FastSaxParser
()
{
{
mxDocumentLocator
.
set
(
new
FastLocatorImpl
(
this
)
);
mxDocumentLocator
.
set
(
new
FastLocatorImpl
(
this
)
);
maUtf8Buffer
.
realloc
(
mnUtf8BufferSize
);
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
@@ -381,31 +380,7 @@ void FastSaxParser::DefineNamespace( const OString& rPrefix, const sal_Char* pNa
...
@@ -381,31 +380,7 @@ void FastSaxParser::DefineNamespace( const OString& rPrefix, const sal_Char* pNa
sal_Int32
FastSaxParser
::
GetToken
(
const
sal_Char
*
pToken
,
sal_Int32
nLen
/* = 0 */
)
sal_Int32
FastSaxParser
::
GetToken
(
const
sal_Char
*
pToken
,
sal_Int32
nLen
/* = 0 */
)
{
{
sal_Int32
nRet
;
return
maTokenLookup
.
getTokenFromChars
(
getEntity
().
mxTokenHandler
,
pToken
,
nLen
);
if
(
!
nLen
)
nLen
=
strlen
(
pToken
);
if
(
nLen
<
mnUtf8BufferSize
)
{
// Get intimiate with the underlying sequence cf. sal/types.h
sal_Sequence
*
pSeq
=
maUtf8Buffer
.
get
();
sal_Int32
nPreRefCount
=
pSeq
->
nRefCount
;
pSeq
->
nElements
=
nLen
;
memcpy
(
pSeq
->
elements
,
pToken
,
nLen
);
nRet
=
getEntity
().
mxTokenHandler
->
getTokenFromUTF8
(
maUtf8Buffer
);
(
void
)
nPreRefCount
;
// for non-debug mode.
assert
(
pSeq
->
nRefCount
==
nPreRefCount
);
// callee must not take ref.
}
else
{
Sequence
<
sal_Int8
>
aSeq
(
(
sal_Int8
*
)
pToken
,
nLen
);
// heap allocate & free
nRet
=
getEntity
().
mxTokenHandler
->
getTokenFromUTF8
(
aSeq
);
}
return
nRet
;
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
...
sax/source/fastparser/fastparser.hxx
Dosyayı görüntüle @
fc25afaa
...
@@ -222,9 +222,7 @@ private:
...
@@ -222,9 +222,7 @@ private:
ParserData
maData
;
/// Cached parser configuration for next call of parseStream().
ParserData
maData
;
/// Cached parser configuration for next call of parseStream().
::
std
::
stack
<
Entity
>
maEntities
;
/// Entity stack for each call of parseStream().
::
std
::
stack
<
Entity
>
maEntities
;
/// Entity stack for each call of parseStream().
FastTokenLookup
maTokenLookup
;
static
const
int
mnUtf8BufferSize
=
128
;
::
css
::
uno
::
Sequence
<
sal_Int8
>
maUtf8Buffer
;
/// avoid constantly re-allocating this
};
};
}
}
...
...
sax/source/tools/fastattribs.cxx
Dosyayı görüntüle @
fc25afaa
...
@@ -114,10 +114,9 @@ sal_Int32 FastAttributeList::getValueToken( ::sal_Int32 Token ) throw (SAXExcept
...
@@ -114,10 +114,9 @@ sal_Int32 FastAttributeList::getValueToken( ::sal_Int32 Token ) throw (SAXExcept
{
{
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
if
(
maAttributeTokens
[
i
]
==
Token
)
if
(
maAttributeTokens
[
i
]
==
Token
)
{
return
maTokenLookup
.
getTokenFromChars
(
mxTokenHandler
,
Sequence
<
sal_Int8
>
aSeq
(
(
sal_Int8
*
)
mpChunk
+
maAttributeValues
[
i
],
AttributeValueLength
(
i
)
);
mpChunk
+
maAttributeValues
[
i
],
return
mxTokenHandler
->
getTokenFromUTF8
(
aSeq
);
AttributeValueLength
(
i
)
);
}
throw
SAXException
();
throw
SAXException
();
}
}
...
@@ -126,10 +125,9 @@ sal_Int32 FastAttributeList::getOptionalValueToken( ::sal_Int32 Token, ::sal_Int
...
@@ -126,10 +125,9 @@ sal_Int32 FastAttributeList::getOptionalValueToken( ::sal_Int32 Token, ::sal_Int
{
{
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
maAttributeTokens
.
size
();
++
i
)
if
(
maAttributeTokens
[
i
]
==
Token
)
if
(
maAttributeTokens
[
i
]
==
Token
)
{
return
maTokenLookup
.
getTokenFromChars
(
mxTokenHandler
,
Sequence
<
sal_Int8
>
aSeq
(
(
sal_Int8
*
)
mpChunk
+
maAttributeValues
[
i
],
AttributeValueLength
(
i
)
);
mpChunk
+
maAttributeValues
[
i
],
return
mxTokenHandler
->
getTokenFromUTF8
(
aSeq
);
AttributeValueLength
(
i
)
);
}
return
Default
;
return
Default
;
}
}
...
@@ -178,6 +176,47 @@ sal_Int32 FastAttributeList::AttributeValueLength(sal_Int32 i)
...
@@ -178,6 +176,47 @@ sal_Int32 FastAttributeList::AttributeValueLength(sal_Int32 i)
return
maAttributeValues
[
i
+
1
]
-
maAttributeValues
[
i
]
-
1
;
return
maAttributeValues
[
i
+
1
]
-
maAttributeValues
[
i
]
-
1
;
}
}
FastTokenLookup
::
FastTokenLookup
()
{
maUtf8Buffer
.
realloc
(
mnUtf8BufferSize
);
}
/**
* Avoid doing any memory allocation if we can, instead keep a
* pet sequence around and do some heavy petting on it.
*/
sal_Int32
FastTokenLookup
::
getTokenFromChars
(
const
::
css
::
uno
::
Reference
<
::
css
::
xml
::
sax
::
XFastTokenHandler
>
&
xTokenHandler
,
const
char
*
pToken
,
size_t
nLen
/* = 0 */
)
{
sal_Int32
nRet
;
if
(
!
nLen
)
nLen
=
strlen
(
pToken
);
if
(
nLen
<
mnUtf8BufferSize
)
{
// Get intimiate with the underlying sequence cf. sal/types.h
sal_Sequence
*
pSeq
=
maUtf8Buffer
.
get
();
sal_Int32
nPreRefCount
=
pSeq
->
nRefCount
;
pSeq
->
nElements
=
nLen
;
memcpy
(
pSeq
->
elements
,
pToken
,
nLen
);
nRet
=
xTokenHandler
->
getTokenFromUTF8
(
maUtf8Buffer
);
(
void
)
nPreRefCount
;
// for non-debug mode.
assert
(
pSeq
->
nRefCount
==
nPreRefCount
);
// callee must not take ref
}
else
{
Sequence
<
sal_Int8
>
aSeq
(
(
sal_Int8
*
)
pToken
,
nLen
);
// heap allocate & free
nRet
=
xTokenHandler
->
getTokenFromUTF8
(
aSeq
);
}
return
nRet
;
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* 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