Skip to content

Commit 838e658

Browse files
Tor Lillqvistcodewithvk
authored andcommitted
Don't use an identifier starting with an underscore and an uppercase letter
Such are reserved for the C++ implementation. It's typical. A day after me complaining about the bad habit of using initial underscores in https://gerrit.libreoffice.org/c/core/+/196572 , I notice that I did it myself just a week or so earlier here, in the freshly written RecentFiles class. Here in online the convention to use an initial underscore for private class members comes from Poco. Ideally we should get rid of all of it. But that will take time. Until then at least we shouldn't use identifiers starting with an undersore and an uppercase letter. Such are definitely reserved. (Identifiers starting with a single underscore and a lowercase letter are apparently OK, but as it is easy to forget exactly what is reserved, IMNSHO it is best to avoid them, too.) Signed-off-by: Tor Lillqvist <[email protected]> Change-Id: I645eef09b5b44d8301b98b0d537d1061875b950f
1 parent 285e80d commit 838e658

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

common/RecentFiles.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void RecentFiles::load(const std::string& fileName, int maxFiles)
5151
uint64_t count;
5252
std::istringstream(line) >> count;
5353
entry.timestamp = std::chrono::time_point<std::chrono::system_clock>(std::chrono::system_clock::duration(count));
54-
_MRU.push_back(entry);
54+
_mostRecentlyUsed.push_back(entry);
5555
}
5656
}
5757
}
@@ -61,13 +61,13 @@ void RecentFiles::add(const std::string& uri)
6161
assert(_initialised);
6262

6363
// Add entry for the file first in the list, removing old entry for it if it exist.
64-
for (auto it = _MRU.begin(); it != _MRU.end(); it++)
64+
for (auto it = _mostRecentlyUsed.begin(); it != _mostRecentlyUsed.end(); it++)
6565
if (it->uri == uri)
6666
{
67-
_MRU.erase(it);
67+
_mostRecentlyUsed.erase(it);
6868
break;
6969
}
70-
_MRU.insert(_MRU.begin(),
70+
_mostRecentlyUsed.insert(_mostRecentlyUsed.begin(),
7171
{ uri, std::chrono::time_point<std::chrono::system_clock>(std::chrono::system_clock::now()) });
7272

7373
// Save the list.
@@ -78,7 +78,7 @@ void RecentFiles::add(const std::string& uri)
7878
LOG_ERR("Could not open '" << _fileName << "' for writing");
7979
return;
8080
}
81-
for (const auto& i : _MRU)
81+
for (const auto& i : _mostRecentlyUsed)
8282
stream << i.uri << std::endl << i.timestamp.time_since_epoch().count() << std::endl;
8383
}
8484

@@ -87,19 +87,19 @@ std::string RecentFiles::serialise()
8787
std::string result;
8888

8989
result = "[ ";
90-
for (int i = 0; i < _MRU.size(); i++)
90+
for (int i = 0; i < _mostRecentlyUsed.size(); i++)
9191
{
9292
std::vector<std::string> segments;
93-
Poco::URI(_MRU[i].uri).getPathSegments(segments);
93+
Poco::URI(_mostRecentlyUsed[i].uri).getPathSegments(segments);
9494

9595
assert(!segments.empty());
9696

9797
result += "{ "
98-
"\"uri\": \"" + _MRU[i].uri + "\", "
98+
"\"uri\": \"" + _mostRecentlyUsed[i].uri + "\", "
9999
"\"name\": \"" + JsonUtil::escapeJSONValue(segments.back()) + "\", "
100-
"\"timestamp\": \"" + std::format("{:%FT%TZ}", _MRU[i].timestamp) + "\""
100+
"\"timestamp\": \"" + std::format("{:%FT%TZ}", _mostRecentlyUsed[i].timestamp) + "\""
101101
" }";
102-
if (i < _MRU.size() - 1)
102+
if (i < _mostRecentlyUsed.size() - 1)
103103
result += ", ";
104104
}
105105
result += " ]";

common/RecentFiles.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class RecentFiles
4747
bool _initialised;
4848

4949
std::string _fileName;
50-
std::vector<Entry> _MRU;
50+
std::vector<Entry> _mostRecentlyUsed;
5151
int _maxFiles;
5252
};
5353

0 commit comments

Comments
 (0)