Skip to content

Commit abea6f2

Browse files
authored
Merge pull request #691 from krlmlr/f-Wconversion-3
Reduce -Wconversion warnings
2 parents ebe67e8 + ac379ca commit abea6f2

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

inst/include/Rcpp/api/meat/module/Module.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
namespace Rcpp {
2424

2525
inline List Module::classes_info(){
26-
int n = classes.size() ;
26+
size_t n = classes.size() ;
2727
CharacterVector names(n) ;
2828
List info(n);
2929
CLASS_MAP::iterator it = classes.begin() ;
3030
std::string buffer ;
31-
for( int i=0; i<n; i++, ++it){
31+
for( size_t i=0; i<n; i++, ++it){
3232
names[i] = it->first ;
3333
info[i] = CppClass( this , it->second, buffer ) ;
3434
}

inst/include/Rcpp/module/Module.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ namespace Rcpp {
7171
* vector of arity of all the functions exported by the module
7272
*/
7373
IntegerVector functions_arity(){
74-
int n = functions.size() ;
74+
size_t n = functions.size() ;
7575
IntegerVector x( n ) ;
7676
CharacterVector names( n );
7777
MAP::iterator it = functions.begin() ;
78-
for( int i=0; i<n; i++, ++it){
78+
for( size_t i=0; i<n; i++, ++it){
7979
x[i] = (it->second)->nargs() ;
8080
names[i] = it->first ;
8181
}
@@ -87,10 +87,10 @@ namespace Rcpp {
8787
* vector of names of the functions
8888
*/
8989
CharacterVector functions_names(){
90-
int n = functions.size() ;
90+
size_t n = functions.size() ;
9191
CharacterVector names( n );
9292
MAP::iterator it = functions.begin() ;
93-
for( int i=0; i<n; i++, ++it){
93+
for( size_t i=0; i<n; i++, ++it){
9494
names[i] = it->first ;
9595
}
9696
return names ;
@@ -100,10 +100,10 @@ namespace Rcpp {
100100
* exposed class names
101101
*/
102102
inline CharacterVector class_names(){
103-
int n = classes.size() ;
103+
size_t n = classes.size() ;
104104
CharacterVector names( n );
105105
CLASS_MAP::iterator it = classes.begin() ;
106-
for( int i=0; i<n; i++, ++it){
106+
for( size_t i=0; i<n; i++, ++it){
107107
names[i] = it->first ;
108108
}
109109
return names ;
@@ -118,11 +118,11 @@ namespace Rcpp {
118118
* completion information
119119
*/
120120
CharacterVector complete(){
121-
int nf = functions.size() ;
122-
int nc = classes.size() ;
123-
int n = nf + nc ;
121+
size_t nf = functions.size() ;
122+
size_t nc = classes.size() ;
123+
size_t n = nf + nc ;
124124
CharacterVector res( n ) ;
125-
int i=0;
125+
size_t i=0;
126126
MAP::iterator it = functions.begin();
127127
std::string buffer ;
128128
for( ; i<nf; i++, ++it) {
@@ -135,7 +135,7 @@ namespace Rcpp {
135135
res[i] = buffer ;
136136
}
137137
CLASS_MAP::iterator cit = classes.begin() ;
138-
for( int j=0; j<nc; j++, i++, ++cit){
138+
for( size_t j=0; j<nc; j++, i++, ++cit){
139139
res[i] = cit->first ;
140140
}
141141
return res ;
@@ -154,9 +154,9 @@ namespace Rcpp {
154154
*/
155155
inline SEXP get_function( const std::string& name_ ){
156156
MAP::iterator it = functions.begin() ;
157-
int n = functions.size() ;
157+
size_t n = functions.size() ;
158158
CppFunction* fun = 0 ;
159-
for( int i=0; i<n; i++, ++it){
159+
for( size_t i=0; i<n; i++, ++it){
160160
if( name_.compare( it->first ) == 0){
161161
fun = it->second ;
162162
break ;
@@ -179,9 +179,9 @@ namespace Rcpp {
179179
*/
180180
inline DL_FUNC get_function_ptr( const std::string& name_ ){
181181
MAP::iterator it = functions.begin() ;
182-
int n = functions.size() ;
182+
size_t n = functions.size() ;
183183
CppFunction* fun = 0 ;
184-
for( int i=0; i<n; i++, ++it){
184+
for( size_t i=0; i<n; i++, ++it){
185185
if( name_.compare( it->first ) == 0){
186186
fun = it->second ;
187187
break ;

0 commit comments

Comments
 (0)