Skip to content

Commit 16dd70c

Browse files
authored
Merge pull request cms-sw#43320 from smuzaffar/classlib-cleanup1
cleanup classlib string List/Format usage
2 parents 34dbaaa + 539beb1 commit 16dd70c

File tree

5 files changed

+11
-23
lines changed

5 files changed

+11
-23
lines changed

DQMServices/Components/plugins/EDMtoMEConverter.cc

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@
4141
#include <vector>
4242
#include <map>
4343
#include <tuple>
44+
#include <filesystem>
4445

4546
#include "TString.h"
4647
#include "TList.h"
4748

48-
#include "classlib/utils/StringList.h"
49-
#include "classlib/utils/StringOps.h"
50-
5149
class EDMtoMEConverter : public edm::one::EDProducer<edm::one::WatchRuns,
5250
edm::one::WatchLuminosityBlocks,
5351
edm::one::SharedResources,
@@ -476,17 +474,12 @@ void EDMtoMEConverter::getData(DQMStore::IBooker &iBooker, DQMStore::IGetter &iG
476474
if (verbosity > 0)
477475
std::cout << pathname << std::endl;
478476

479-
std::string dir;
480-
481477
// deconstruct path from fullpath
482-
StringList fulldir = StringOps::split(pathname, "/");
483-
std::string name = *(fulldir.end() - 1);
484-
485-
for (unsigned j = 0; j < fulldir.size() - 1; ++j) {
486-
dir += fulldir[j];
487-
if (j != fulldir.size() - 2)
488-
dir += "/";
489-
}
478+
std::filesystem::path fulldir(pathname);
479+
std::string name = fulldir.filename();
480+
std::string dir = fulldir.parent_path();
481+
if (dir == "/")
482+
dir = "";
490483

491484
// define new monitor element
492485
adjustScope(iBooker, iGetFrom, reScope);

DQMServices/Core/BuildFile.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<use name="protobuf"/>
33
<use name="roothistmatrix"/>
44
<use name="tbb"/>
5+
<use name="fmt"/>
56
<use name="FWCore/Framework"/>
67
<use name="FWCore/ParameterSet"/>
78
<use name="FWCore/ServiceRegistry"/>

DQMServices/Core/interface/DQMNet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "classlib/iobase/Socket.h"
55
#include "classlib/iobase/IOSelector.h"
66
#include "classlib/iobase/Pipe.h"
7-
#include "classlib/utils/Signal.h"
87
#include "classlib/utils/Error.h"
98
#include "classlib/utils/Time.h"
109
#include <pthread.h>

DQMServices/Core/src/DQMNet.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#include "DQMServices/Core/interface/DQMNet.h"
22
#include "classlib/iobase/InetServerSocket.h"
33
#include "classlib/iobase/LocalServerSocket.h"
4-
#include "classlib/iobase/Filename.h"
54
#include "classlib/sysapi/InetSocket.h" // for completing InetAddress
6-
#include "classlib/utils/TimeInfo.h"
7-
#include "classlib/utils/StringList.h"
8-
#include "classlib/utils/StringFormat.h"
9-
#include "classlib/utils/StringOps.h"
105
#include "classlib/utils/SystemError.h"
116
#include "classlib/utils/Regexp.h"
7+
#include <fmt/format.h>
128
#include <unistd.h>
139
#include <fcntl.h>
1410
#include <sys/wait.h>
@@ -832,8 +828,8 @@ bool DQMNet::onPeerConnect(IOSelectEvent *ev) {
832828
if (auto *inet = dynamic_cast<InetSocket *>(s)) {
833829
InetAddress peeraddr = inet->peername();
834830
InetAddress myaddr = inet->sockname();
835-
p->peeraddr = StringFormat("%1:%2").arg(peeraddr.hostname()).arg(peeraddr.port()).value();
836-
localaddr = StringFormat("%1:%2").arg(myaddr.hostname()).arg(myaddr.port()).value();
831+
p->peeraddr = fmt::format("{}:{}", peeraddr.hostname(), peeraddr.port());
832+
localaddr = fmt::format("{}:{}", myaddr.hostname(), myaddr.port());
837833
} else if (auto *local = dynamic_cast<LocalSocket *>(s)) {
838834
p->peeraddr = local->peername().path();
839835
localaddr = local->sockname().path();
@@ -1130,7 +1126,7 @@ void DQMNet::run() {
11301126

11311127
InetAddress peeraddr = ((InetSocket *)s)->peername();
11321128
InetAddress myaddr = ((InetSocket *)s)->sockname();
1133-
p->peeraddr = StringFormat("%1:%2").arg(peeraddr.hostname()).arg(peeraddr.port()).value();
1129+
p->peeraddr = fmt::format("{}:{}", peeraddr.hostname(), peeraddr.port());
11341130
p->mask = IORead | IOWrite | IOUrgent;
11351131
p->update = ap->update;
11361132
p->automatic = ap;

DQMServices/Core/src/DQMService.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "DQMServices/Core/interface/DQMScope.h"
55
#include "DQMServices/Core/interface/MonitorElement.h"
66
#include "FWCore/ServiceRegistry/interface/Service.h"
7-
#include "classlib/utils/Error.h"
87
#include <mutex>
98
#include <iostream>
109
#include <string>

0 commit comments

Comments
 (0)