mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Replace static with thread_local when used for caching
thread_local is a per-thread static variable, so it is thread-safe and can be used for caching purpose. Remove the cache for parameter lists as discussed on the list http://mid.gmane.org/6e871431-0e87-ed2a-3e31-b63356c2391e@lyx.org. (requires gcc >= 4.8)
This commit is contained in:
parent
0090af19d3
commit
82d4f1a446
@ -571,6 +571,7 @@ void GuiCitation::findKey(BiblioInfo const & bi,
|
||||
bool case_sensitive, bool reg_exp, bool reset)
|
||||
{
|
||||
// FIXME THREAD
|
||||
// This should be moved to a class member.
|
||||
// Used for optimisation: store last searched string.
|
||||
static QString last_searched_string;
|
||||
// Used to disable the above optimisation.
|
||||
|
@ -1496,21 +1496,10 @@ void GuiDocument::includeonlyClicked(QTreeWidgetItem * item, int)
|
||||
|
||||
QString GuiDocument::validateListingsParameters()
|
||||
{
|
||||
// use a cache here to avoid repeated validation
|
||||
// of the same parameters
|
||||
// FIXME THREAD
|
||||
static string param_cache;
|
||||
static QString msg_cache;
|
||||
|
||||
if (listingsModule->bypassCB->isChecked())
|
||||
return QString();
|
||||
|
||||
string params = fromqstr(listingsModule->listingsED->toPlainText());
|
||||
if (params != param_cache) {
|
||||
param_cache = params;
|
||||
msg_cache = toqstr(InsetListingsParams(params).validate());
|
||||
}
|
||||
return msg_cache;
|
||||
return toqstr(InsetListingsParams(params).validate());
|
||||
}
|
||||
|
||||
|
||||
|
@ -373,9 +373,13 @@ GuiFontInfo::GuiFontInfo(FontInfo const & f)
|
||||
|
||||
bool FontLoader::available(FontInfo const & f)
|
||||
{
|
||||
// FIXME THREAD
|
||||
static vector<int> cache_set(NUM_FAMILIES, false);
|
||||
static vector<int> cache(NUM_FAMILIES, false);
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
|
||||
static vector<bool> cache_set(NUM_FAMILIES, false);
|
||||
static vector<bool> cache(NUM_FAMILIES, false);
|
||||
#else
|
||||
thread_local vector<bool> cache_set(NUM_FAMILIES, false);
|
||||
thread_local vector<bool> cache(NUM_FAMILIES, false);
|
||||
#endif
|
||||
|
||||
FontFamily family = f.family();
|
||||
#ifdef Q_OS_MAC
|
||||
|
@ -91,21 +91,10 @@ void GuiInclude::change_adaptor()
|
||||
|
||||
docstring GuiInclude::validate_listings_params()
|
||||
{
|
||||
// use a cache here to avoid repeated validation
|
||||
// of the same parameters
|
||||
// FIXME THREAD
|
||||
static string param_cache = string();
|
||||
static docstring msg_cache = docstring();
|
||||
|
||||
if (typeCO->currentIndex() != 3 || bypassCB->isChecked())
|
||||
return docstring();
|
||||
|
||||
string params = fromqstr(listingsED->toPlainText());
|
||||
if (params != param_cache) {
|
||||
param_cache = params;
|
||||
msg_cache = InsetListingsParams(params).validate();
|
||||
}
|
||||
return msg_cache;
|
||||
return InsetListingsParams(params).validate();
|
||||
}
|
||||
|
||||
|
||||
|
@ -346,21 +346,9 @@ string GuiListings::construct_params()
|
||||
|
||||
docstring GuiListings::validate_listings_params()
|
||||
{
|
||||
// use a cache here to avoid repeated validation
|
||||
// of the same parameters
|
||||
// FIXME THREAD
|
||||
static string param_cache;
|
||||
static docstring msg_cache;
|
||||
|
||||
if (bypassCB->isChecked())
|
||||
return docstring();
|
||||
|
||||
string params = construct_params();
|
||||
if (params != param_cache) {
|
||||
param_cache = params;
|
||||
msg_cache = InsetListingsParams(params).validate();
|
||||
}
|
||||
return msg_cache;
|
||||
return InsetListingsParams(construct_params()).validate();
|
||||
}
|
||||
|
||||
|
||||
|
@ -208,11 +208,16 @@ void GuiPainter::lines(int const * xp, int const * yp, int np,
|
||||
return;
|
||||
|
||||
// double the size if needed
|
||||
// FIXME THREAD
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
|
||||
static QVector<QPoint> points(32);
|
||||
#else
|
||||
thread_local QVector<QPoint> points(32);
|
||||
#endif
|
||||
if (np > points.size())
|
||||
points.resize(2 * np);
|
||||
|
||||
// Note: the proper way to not get blurry vertical and horizontal lines is
|
||||
// to add 0.5 to all coordinates.
|
||||
bool antialias = false;
|
||||
for (int i = 0; i < np; ++i) {
|
||||
points[i].setX(xp[i]);
|
||||
|
@ -152,8 +152,11 @@ const int no_blocks = sizeof(unicode_blocks) / sizeof(UnicodeBlocks);
|
||||
QString getBlock(char_type c)
|
||||
{
|
||||
// store an educated guess for the next search
|
||||
// FIXME THREAD
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
|
||||
static int lastBlock = 0;
|
||||
#else
|
||||
thread_local int lastBlock = 0;
|
||||
#endif
|
||||
|
||||
// "clever reset"
|
||||
if (c < 0x7f)
|
||||
|
Loading…
Reference in New Issue
Block a user