Skip to content

Commit 79460bc

Browse files
committed
changed Timer.h to re-enable build under current g++
1 parent 4b90acc commit 79460bc

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2014-01-25 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/Benchmark/Timer.h: Simplified -- Rcpp Gallery
4+
example using it was not building any longer under g++
5+
16
2014-01-23 Dirk Eddelbuettel <[email protected]>
27

38
* inst/announce/ANNOUNCE-0.11.0.txt: Added for next release

DESCRIPTION

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 0.10.6.8
4-
Date: 2014-01-19
5-
Authors@R: c(
6-
person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]" ),
7-
person("Romain", "Francois", role = "aut", email = "[email protected]"),
8-
person("JJ", "Allaire", role = "ctb", email = "[email protected]"),
9-
person("John", "Chambers", role = "ctb", email = "[email protected]"),
10-
person("Douglas", "Bates", role = "ctb", email = "[email protected]"),
11-
person("Kevin", "Ushey", role = "ctb", email = "[email protected]")
12-
)
3+
Version: 0.10.6.9
4+
Date: 2014-01-25
5+
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]" ),
6+
person("Romain", "Francois", role = "aut", email = "[email protected]"),
7+
person("JJ", "Allaire", role = "ctb", email = "[email protected]"),
8+
person("John", "Chambers", role = "ctb", email = "[email protected]"),
9+
person("Douglas", "Bates", role = "ctb", email = "[email protected]"),
10+
person("Kevin", "Ushey", role = "ctb", email = "[email protected]"))
1311
Description: The Rcpp package provides R functions as well as a C++ library
1412
which facilitate the integration of R and C++.
1513
.

inst/include/Rcpp/Benchmark/Timer.h

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
1+
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
22
//
33
// Timer.h: Rcpp R/C++ interface class library -- Rcpp benchmark utility
44
//
5-
// Copyright (C) 2012 - 2013 JJ Allaire, Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2012 - 2014 JJ Allaire, Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -106,34 +106,30 @@ namespace Rcpp{
106106
Timer() : data(), start_time( get_nanotime() ){}
107107

108108
void step( const std::string& name){
109-
nanotime_t now = get_nanotime() ;
110-
data.push_back( std::make_pair( name, now - start_time ) ) ;
111-
start_time = get_nanotime() ;
109+
nanotime_t now = get_nanotime();
110+
data.push_back(std::make_pair(name, now - start_time));
111+
start_time = get_nanotime();
112112
}
113113

114114
operator SEXP() const {
115-
NumericVector out( data.begin(), data.end(), get_second ) ;
116-
CharacterVector names( data.begin(), data.end(), get_first ) ;
117-
out.attr( "names" ) = names ;
118-
return out ;
115+
size_t n = data.size();
116+
NumericVector out(n);
117+
CharacterVector names(n);
118+
for (size_t i=0; i<n; i++) {
119+
names[i] = data[i].first;
120+
out[i] = data[i].second;
121+
}
122+
out.attr("names") = names;
123+
return out;
119124
}
120125

121126
private:
122-
123-
inline std::string get_first( const std::pair<std::string,nanotime_t>& pair ){
124-
return pair.first ;
125-
}
126-
inline double get_second( const std::pair<std::string,nanotime_t>& pair ){
127-
return static_cast<double>(pair.second) ;
128-
}
129-
130127
typedef std::pair<std::string,nanotime_t> Step;
131128
typedef std::vector<Step> Steps;
132129

133-
Steps data ;
134-
nanotime_t start_time ;
135-
136-
} ;
130+
Steps data;
131+
nanotime_t start_time;
132+
};
137133

138134
}
139135

0 commit comments

Comments
 (0)