From dcd1b2194f3ddfbcd6a5aa7847240486a11f4a59 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 17 May 2017 00:12:37 -0700 Subject: [PATCH] Fix size_t conversion warnings --- src/indexgenerator.cpp | 4 ++-- src/overdrawoptimizer.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/indexgenerator.cpp b/src/indexgenerator.cpp index 8774d185..3927b26d 100644 --- a/src/indexgenerator.cpp +++ b/src/indexgenerator.cpp @@ -10,7 +10,7 @@ namespace const unsigned int m = 0x5bd1e995; const int r = 24; - unsigned int h = seed ^ len; + unsigned int h = seed ^ static_cast(len); // Mix 4 bytes at a time into the hash const unsigned char* data = (const unsigned char*)key; @@ -89,7 +89,7 @@ namespace { assert((table.size() & (table.size() - 1)) == 0); - unsigned int hash = hasher(key); + size_t hash = hasher(key); size_t hashmod = table.size() - 1; size_t bucket = hash & hashmod; diff --git a/src/overdrawoptimizer.cpp b/src/overdrawoptimizer.cpp index 9d50f750..ed4cdb6a 100644 --- a/src/overdrawoptimizer.cpp +++ b/src/overdrawoptimizer.cpp @@ -146,8 +146,8 @@ namespace size_t face_count = index_count / 3; size_t vertex_stride_float = vertex_positions_stride / sizeof(float); - unsigned int current_cluster = 0; - unsigned int next_cluster_face = (clusters.size() > 1) ? clusters[1] : face_count; + size_t current_cluster = 0; + size_t next_cluster_face = (clusters.size() > 1) ? clusters[1] : face_count; float cluster_area = 0; float mesh_area = 0; @@ -220,7 +220,7 @@ namespace { unsigned int cluster = sort_data[i].cluster; - unsigned int next_cluster_face = (clusters.size() > cluster + 1) ? clusters[cluster + 1] : index_count / 3; + size_t next_cluster_face = (clusters.size() > cluster + 1) ? clusters[cluster + 1] : index_count / 3; for (size_t j = clusters[cluster] * 3; j < next_cluster_face * 3; ++j) *dest_it++ = indices[j]; @@ -230,7 +230,7 @@ namespace } template - std::pair calculateACMR(const T* indices, size_t index_count, unsigned int cache_size, float threshold, std::vector& cache_time_stamps, unsigned int& time_stamp) + std::pair calculateACMR(const T* indices, size_t index_count, unsigned int cache_size, float threshold, std::vector& cache_time_stamps, unsigned int& time_stamp) { // Ensures that all vertices are not in cache assert(time_stamp <= static_cast(-1) - (cache_size + 1)); @@ -289,7 +289,7 @@ namespace std::vector cache_time_stamps(vertex_count, 0); unsigned int time_stamp = 0; - std::pair p = calculateACMR(indices, index_count, cache_size, 0, cache_time_stamps, time_stamp); + std::pair p = calculateACMR(indices, index_count, cache_size, 0, cache_time_stamps, time_stamp); assert(p.second == index_count / 3); @@ -297,14 +297,14 @@ namespace for (size_t it = 0; it < clusters.size(); ++it) { - unsigned int start = clusters[it]; - unsigned int end = (it + 1 < clusters.size()) ? clusters[it + 1] : index_count / 3; + size_t start = clusters[it]; + size_t end = (it + 1 < clusters.size()) ? clusters[it + 1] : index_count / 3; while (start != end) { - std::pair cp = calculateACMR(indices + start * 3, (end - start) * 3, cache_size, acmr_threshold, cache_time_stamps, time_stamp); + std::pair cp = calculateACMR(indices + start * 3, (end - start) * 3, cache_size, acmr_threshold, cache_time_stamps, time_stamp); - destination.push_back(start); + destination.push_back(static_cast(start)); start += cp.second; } }