File tree 1 file changed +10
-19
lines changed
1 file changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -57,18 +57,16 @@ void BanManager::load()
57
57
throw SerializationError (" BanManager::load(): Couldn't open file" );
58
58
}
59
59
60
- for (;; )
60
+ while (!is. eof () && is. good () )
61
61
{
62
- if (is.eof () || is.good () == false )
63
- break ;
64
62
std::string line;
65
63
std::getline (is, line, ' \n ' );
66
64
Strfnd f (line);
67
65
std::string ip = trim (f.next (" |" ));
68
66
std::string name = trim (f.next (" |" ));
69
- if (ip.empty ())
70
- continue ;
71
- m_ips[ip] = name;
67
+ if (! ip.empty ()) {
68
+ m_ips[ip] = name ;
69
+ }
72
70
}
73
71
m_modified = false ;
74
72
}
@@ -135,22 +133,15 @@ void BanManager::add(const std::string &ip, const std::string &name)
135
133
void BanManager::remove (const std::string &ip_or_name)
136
134
{
137
135
JMutexAutoLock lock (m_mutex);
138
- // m_ips.erase(m_ips.find(ip));
139
- // Find out all ip-name pairs that match the ip or name
140
- std::set<std::string> ips_to_delete;
141
136
for (std::map<std::string, std::string>::iterator
142
137
i = m_ips.begin ();
143
- i != m_ips.end (); i++)
144
- {
145
- if (i->first == ip_or_name || i->second == ip_or_name)
146
- ips_to_delete.insert (i->first );
147
- }
148
- // Erase them
149
- for (std::set<std::string>::iterator
150
- i = ips_to_delete.begin ();
151
- i != ips_to_delete.end (); i++)
138
+ i != m_ips.end ();)
152
139
{
153
- m_ips.erase (*i);
140
+ if ((i->first == ip_or_name) || (i->second == ip_or_name)) {
141
+ m_ips.erase (i++);
142
+ } else {
143
+ ++i;
144
+ }
154
145
}
155
146
m_modified = true ;
156
147
}
You can’t perform that action at this time.
0 commit comments