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
4b3e4c1c
Kaydet (Commit)
4b3e4c1c
authored
Kas 15, 2017
tarafından
Dennis Francis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
cache FormulaToken for doubles
Change-Id: Ic0b4dff6f03ef3f88bd150e798fa2d83dfb0f486
üst
9c88d6f2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
6 deletions
+55
-6
token.cxx
formula/source/core/api/token.cxx
+10
-0
token.hxx
include/formula/token.hxx
+2
-0
interpre.hxx
sc/source/core/inc/interpre.hxx
+4
-0
interpr4.cxx
sc/source/core/tool/interpr4.cxx
+39
-6
No files found.
formula/source/core/api/token.cxx
Dosyayı görüntüle @
4b3e4c1c
...
...
@@ -216,6 +216,11 @@ short FormulaToken::GetDoubleType() const
return
0
;
}
void
FormulaToken
::
SetDoubleType
(
short
)
{
SAL_WARN
(
"formula.core"
,
"FormulaToken::SetDoubleType: virtual dummy called"
);
}
svl
::
SharedString
FormulaToken
::
GetString
()
const
{
SAL_WARN
(
"formula.core"
,
"FormulaToken::GetString: virtual dummy called"
);
...
...
@@ -1797,6 +1802,11 @@ short FormulaTypedDoubleToken::GetDoubleType() const
return
mnType
;
}
void
FormulaTypedDoubleToken
::
SetDoubleType
(
short
nType
)
{
mnType
=
nType
;
}
bool
FormulaTypedDoubleToken
::
operator
==
(
const
FormulaToken
&
r
)
const
{
return
FormulaDoubleToken
::
operator
==
(
r
)
&&
mnType
==
r
.
GetDoubleType
();
...
...
include/formula/token.hxx
Dosyayı görüntüle @
4b3e4c1c
...
...
@@ -181,6 +181,7 @@ public:
virtual
double
GetDouble
()
const
;
virtual
double
&
GetDoubleAsReference
();
virtual
short
GetDoubleType
()
const
;
virtual
void
SetDoubleType
(
short
nType
);
virtual
svl
::
SharedString
GetString
()
const
;
virtual
void
SetString
(
const
svl
::
SharedString
&
rStr
);
virtual
sal_uInt16
GetIndex
()
const
;
...
...
@@ -321,6 +322,7 @@ public:
virtual
FormulaToken
*
Clone
()
const
override
{
return
new
FormulaTypedDoubleToken
(
*
this
);
}
virtual
short
GetDoubleType
()
const
override
;
virtual
void
SetDoubleType
(
short
nType
)
override
;
virtual
bool
operator
==
(
const
FormulaToken
&
rToken
)
const
override
;
DECL_FIXEDMEMPOOL_NEWDEL_DLL
(
FormulaTypedDoubleToken
)
...
...
sc/source/core/inc/interpre.hxx
Dosyayı görüntüle @
4b3e4c1c
...
...
@@ -97,6 +97,7 @@ class SharedStringPool;
}
#define MAXSTACK (4096 / sizeof(formula::FormulaToken*))
#define TOKEN_CACHE_SIZE 8
class
ScTokenStack
{
...
...
@@ -229,6 +230,8 @@ private:
bool
bMatrixFormula
;
// formula cell is a matrix formula
VolatileType
meVolatileType
;
size_t
mnTokenCachePos
;
std
::
vector
<
formula
::
FormulaToken
*>
maTokenCache
;
/// Merge global and document specific settings.
void
MergeCalcConfig
();
...
...
@@ -395,6 +398,7 @@ private:
sc
::
RangeMatrix
PopRangeMatrix
();
void
QueryMatrixType
(
const
ScMatrixRef
&
xMat
,
short
&
rRetTypeExpr
,
sal_uLong
&
rRetIndexExpr
);
formula
::
FormulaToken
*
CreateFormulaDoubleToken
(
double
fVal
,
short
nFmt
=
css
::
util
::
NumberFormat
::
NUMBER
);
formula
::
FormulaToken
*
CreateDoubleOrTypedToken
(
double
fVal
);
void
PushDouble
(
double
nVal
);
...
...
sc/source/core/tool/interpr4.cxx
Dosyayı görüntüle @
4b3e4c1c
...
...
@@ -731,7 +731,7 @@ void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString,
{
TreatDoubleError
(
fVal
);
if
(
!
IfErrorPushError
())
PushTempTokenWithoutError
(
new
FormulaDoubleToken
(
fVal
));
PushTempTokenWithoutError
(
Create
FormulaDoubleToken
(
fVal
));
}
else
{
...
...
@@ -1687,7 +1687,7 @@ void ScInterpreter::QueryMatrixType(const ScMatrixRef& xMat, short& rRetTypeExpr
{
if
(
xMat
->
IsEmptyPath
(
0
,
0
))
{
// result of empty FALSE jump path
FormulaTokenRef
xRes
=
new
FormulaDoubleToken
(
0.0
);
FormulaTokenRef
xRes
=
Create
FormulaDoubleToken
(
0.0
);
PushTempToken
(
new
ScMatrixFormulaCellToken
(
nCols
,
nRows
,
xMat
,
xRes
.
get
()));
rRetTypeExpr
=
css
::
util
::
NumberFormat
::
LOGICAL
;
}
...
...
@@ -1716,7 +1716,7 @@ void ScInterpreter::QueryMatrixType(const ScMatrixRef& xMat, short& rRetTypeExpr
if
(
nErr
!=
FormulaError
::
NONE
)
xRes
=
new
FormulaErrorToken
(
nErr
);
else
xRes
=
new
FormulaDoubleToken
(
nMatVal
.
fVal
);
xRes
=
Create
FormulaDoubleToken
(
nMatVal
.
fVal
);
PushTempToken
(
new
ScMatrixFormulaCellToken
(
nCols
,
nRows
,
xMat
,
xRes
.
get
()));
if
(
rRetTypeExpr
!=
css
::
util
::
NumberFormat
::
LOGICAL
)
rRetTypeExpr
=
css
::
util
::
NumberFormat
::
NUMBER
;
...
...
@@ -1728,14 +1728,42 @@ void ScInterpreter::QueryMatrixType(const ScMatrixRef& xMat, short& rRetTypeExpr
SetError
(
FormulaError
::
UnknownStackVariable
);
}
formula
::
FormulaToken
*
ScInterpreter
::
CreateFormulaDoubleToken
(
double
fVal
,
short
nFmt
)
{
if
(
maTokenCache
.
size
()
!=
TOKEN_CACHE_SIZE
)
maTokenCache
.
resize
(
TOKEN_CACHE_SIZE
);
// Find a spare token
for
(
auto
p
:
maTokenCache
)
{
if
(
p
&&
p
->
GetRef
()
==
1
)
{
p
->
IncRef
();
p
->
GetDoubleAsReference
()
=
fVal
;
p
->
SetDoubleType
(
nFmt
);
return
p
;
}
}
// Allocate a new token
auto
p
=
new
FormulaTypedDoubleToken
(
fVal
,
nFmt
);
size_t
pos
=
(
mnTokenCachePos
++
)
%
TOKEN_CACHE_SIZE
;
if
(
maTokenCache
[
pos
]
)
maTokenCache
[
pos
]
->
DecRef
();
maTokenCache
[
pos
]
=
p
;
p
->
IncRef
();
return
p
;
}
formula
::
FormulaToken
*
ScInterpreter
::
CreateDoubleOrTypedToken
(
double
fVal
)
{
// NumberFormat::NUMBER is the default untyped double.
if
(
nFuncFmtType
&&
nFuncFmtType
!=
css
::
util
::
NumberFormat
::
NUMBER
&&
nFuncFmtType
!=
css
::
util
::
NumberFormat
::
UNDEFINED
)
return
new
FormulaTyped
DoubleToken
(
fVal
,
nFuncFmtType
);
return
CreateFormula
DoubleToken
(
fVal
,
nFuncFmtType
);
else
return
new
FormulaDoubleToken
(
fVal
);
return
Create
FormulaDoubleToken
(
fVal
);
}
void
ScInterpreter
::
PushDouble
(
double
nVal
)
...
...
@@ -3843,6 +3871,11 @@ ScInterpreter::~ScInterpreter()
else
delete
pStackObj
;
delete
pTokenMatrixMap
;
for
(
auto
p
:
maTokenCache
)
if
(
p
&&
p
->
GetRef
()
==
1
)
p
->
DecRef
();
}
ScCalcConfig
&
ScInterpreter
::
GetOrCreateGlobalConfig
()
...
...
@@ -4584,7 +4617,7 @@ StackVar ScInterpreter::Interpret()
nRetIndexExpr
=
0
;
// carry format index only for matching type
nRetTypeExpr
=
nFuncFmtType
=
nCurFmtType
;
}
PushTempToken
(
new
FormulaDoubleToken
(
fVal
));
PushTempToken
(
Create
FormulaDoubleToken
(
fVal
));
}
if
(
nFuncFmtType
==
css
::
util
::
NumberFormat
::
UNDEFINED
)
{
...
...
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