mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Make some code that handle authors more readable
Create accssors authodmap() in BufferParams. Use [] operator instead of find(). Hopefully this will avoid to confuse Coverity scan.
This commit is contained in:
parent
54601b5578
commit
3f5b836aa9
@ -341,6 +341,7 @@ public:
|
||||
Impl();
|
||||
|
||||
AuthorList authorlist;
|
||||
AuthorMap authormap;
|
||||
BranchList branchlist;
|
||||
WordLangTable spellignore;
|
||||
Bullet temp_bullets[4];
|
||||
@ -494,7 +495,7 @@ BufferParams::BufferParams()
|
||||
use_lineno = false;
|
||||
|
||||
// map current author
|
||||
author_map_[pimpl_->authorlist.get(0).bufferId()] = 0;
|
||||
pimpl_->authormap[pimpl_->authorlist.get(0).bufferId()] = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -578,9 +579,21 @@ AuthorList const & BufferParams::authors() const
|
||||
}
|
||||
|
||||
|
||||
BufferParams::AuthorMap & BufferParams::authormap()
|
||||
{
|
||||
return pimpl_->authormap;
|
||||
}
|
||||
|
||||
|
||||
BufferParams::AuthorMap const & BufferParams::authormap() const
|
||||
{
|
||||
return pimpl_->authormap;
|
||||
}
|
||||
|
||||
|
||||
void BufferParams::addAuthor(Author const & a)
|
||||
{
|
||||
author_map_[a.bufferId()] = pimpl_->authorlist.record(a);
|
||||
pimpl_->authormap[a.bufferId()] = pimpl_->authorlist.record(a);
|
||||
}
|
||||
|
||||
|
||||
|
@ -494,7 +494,8 @@ public:
|
||||
|
||||
/// map of the file's author IDs to AuthorList indexes
|
||||
typedef std::map<int, int> AuthorMap;
|
||||
AuthorMap author_map_;
|
||||
AuthorMap & authormap();
|
||||
AuthorMap const & authormap() const;
|
||||
|
||||
/// the buffer's active font encoding
|
||||
std::string const main_font_encoding() const;
|
||||
|
@ -594,7 +594,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
|
||||
int aid;
|
||||
time_t ct;
|
||||
is >> aid >> ct;
|
||||
BufferParams::AuthorMap const & am = bp.author_map_;
|
||||
BufferParams::AuthorMap & am = bp.authormap();
|
||||
if (am.find(aid) == am.end()) {
|
||||
errorList.push_back(ErrorItem(
|
||||
_("Change tracking author index missing"),
|
||||
@ -609,9 +609,9 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
|
||||
bp.addAuthor(Author(aid));
|
||||
}
|
||||
if (token == "\\change_inserted")
|
||||
change = Change(Change::INSERTED, am.find(aid)->second, ct);
|
||||
change = Change(Change::INSERTED, am[aid], ct);
|
||||
else
|
||||
change = Change(Change::DELETED, am.find(aid)->second, ct);
|
||||
change = Change(Change::DELETED, am[aid], ct);
|
||||
} else {
|
||||
lex.eatLine();
|
||||
errorList.push_back(ErrorItem(_("Unknown token"),
|
||||
|
@ -470,7 +470,7 @@ bool getTokenValue(string const & str, char const * token, Change & change, Buff
|
||||
"is incomplete. I will ignore this."));
|
||||
return false;
|
||||
}
|
||||
BufferParams::AuthorMap const & am = bp.author_map_;
|
||||
BufferParams::AuthorMap & am = bp.authormap();
|
||||
int aid = convert<int>(changedata[1]);
|
||||
if (am.find(aid) == am.end()) {
|
||||
// FIXME Use ErrorList
|
||||
@ -488,10 +488,10 @@ bool getTokenValue(string const & str, char const * token, Change & change, Buff
|
||||
time_t ct;
|
||||
is >> ct;
|
||||
if (changedata[0] == "inserted") {
|
||||
change = Change(Change::INSERTED, am.find(aid)->second, ct);
|
||||
change = Change(Change::INSERTED, am[aid], ct);
|
||||
return true;
|
||||
} else if (changedata[0] == "deleted") {
|
||||
change = Change(Change::DELETED, am.find(aid)->second, ct);
|
||||
change = Change(Change::DELETED, am[aid], ct);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user