Skip to content

Commit

Permalink
Update TfSpan::index_type to be std::size_t instead of std::ptrdiff_t.
Browse files Browse the repository at this point in the history
(Internal change: 1969527)
  • Loading branch information
c64kernal authored and pixar-oss committed May 13, 2019
1 parent 4ba9136 commit 5ad0b2f
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion pxr/base/lib/tf/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TfSpan
using value_type = typename std::remove_cv<T>::type;
using pointer = T*;
using reference = T&;
using index_type = std::ptrdiff_t;
using index_type = std::size_t;
using difference_type = std::ptrdiff_t;

using iterator = T*;
Expand Down
2 changes: 1 addition & 1 deletion pxr/base/lib/tf/testenv/testTfSpan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int main(int argc, char** argv)
// Test span edits.
{
TfSpan<int> span(data);
for (ptrdiff_t i = 0; i < span.size(); ++i) {
for (size_t i = 0; i < span.size(); ++i) {
span[i] = (i+1)*10;
}

Expand Down
8 changes: 4 additions & 4 deletions pxr/base/lib/vt/testenv/testVtCpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ static void testArray() {
TfSpan<const int> span = copy;
// Make sure we didn't detach.
TF_AXIOM(span.data() == constData.cdata());
TF_AXIOM(span.size() == static_cast<std::ptrdiff_t>(copy.size()));
TF_AXIOM(span.size() == copy.size());
}
{
VtIntArray copy(constData);

auto span = TfMakeConstSpan(copy);
// Make sure we didn't detach.
TF_AXIOM(span.data() == constData.cdata());
TF_AXIOM(span.size() == static_cast<std::ptrdiff_t>(copy.size()));
TF_AXIOM(span.size() == copy.size());
}

{
Expand All @@ -296,7 +296,7 @@ static void testArray() {
// Should have detached.
TF_AXIOM(span.data() == copy.cdata() &&
span.data() != constData.cdata());
TF_AXIOM(span.size() == static_cast<std::ptrdiff_t>(copy.size()));
TF_AXIOM(span.size() == copy.size());
}

{
Expand All @@ -306,7 +306,7 @@ static void testArray() {
// Should have detached.
TF_AXIOM(span.data() == copy.cdata() &&
span.data() != constData.cdata());
TF_AXIOM(span.size() == static_cast<std::ptrdiff_t>(copy.size()));
TF_AXIOM(span.size() == copy.size());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pxr/usd/lib/usdSkel/bindingAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ UsdSkelBindingAPI::ValidateJointIndices(TfSpan<const int> indices,
size_t numJoints,
std::string* reason)
{
for (ptrdiff_t i = 0; i < indices.size(); ++i) {
for (size_t i = 0; i < indices.size(); ++i) {
const int jointIndex = indices[i];
if (jointIndex < 0 || static_cast<size_t>(jointIndex) >= numJoints) {
if (reason) {
Expand Down
2 changes: 1 addition & 1 deletion pxr/usd/lib/usdSkel/blendShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ UsdSkelBlendShape::ValidatePointIndices(TfSpan<const int> indices,
size_t numPoints,
std::string* reason)
{
for (ptrdiff_t i = 0; i < indices.size(); ++i) {
for (size_t i = 0; i < indices.size(); ++i) {
const unsigned pointIndex = indices[i];
if (pointIndex >= numPoints) {
if (reason) {
Expand Down
6 changes: 3 additions & 3 deletions pxr/usd/lib/usdSkel/blendShapeQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ UsdSkelBlendShapeQuery::ComputeSubShapeWeights(
blendShapeIndices->reserve(weights.size()*2);
subShapeIndices->reserve(weights.size()*2);

for (ptrdiff_t i = 0; i < weights.size(); ++i) {
for (size_t i = 0; i < weights.size(); ++i) {

const _BlendShape& blendShape = _blendShapes[i];

Expand Down Expand Up @@ -350,7 +350,7 @@ UsdSkelBlendShapeQuery::ComputeDeformedPoints(
return false;
}

for (ptrdiff_t i = 0; i < subShapeWeights.size(); ++i) {
for (size_t i = 0; i < subShapeWeights.size(); ++i) {
const unsigned blendShapeIndex = blendShapeIndices[i];
if (blendShapeIndex < blendShapePointIndices.size()) {
const unsigned subShapeIndex = subShapeIndices[i];
Expand Down Expand Up @@ -393,7 +393,7 @@ _ComputeRangesFromCounts(const TfSpan<const unsigned>& counts,
TF_AXIOM(counts.size() == ranges.size());

unsigned start = 0;
for (ptrdiff_t i = 0; i < counts.size(); ++i) {
for (size_t i = 0; i < counts.size(); ++i) {
const unsigned count = counts[i];
ranges[i] = GfVec2i(start, start+count);
start += count;
Expand Down
2 changes: 1 addition & 1 deletion pxr/usd/lib/usdSkel/skeletonQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ _MultTransforms(TfSpan<const Matrix4> a,
{
TF_DEV_AXIOM(a.size() == b.size() && a.size() == out.size());

for (ptrdiff_t i = 0; i < out.size(); ++i) {
for (size_t i = 0; i < out.size(); ++i) {
out[i] = a[i] * b[i];
}
}
Expand Down
6 changes: 3 additions & 3 deletions pxr/usd/lib/usdSkel/topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ _ComputeParentIndicesFromPaths(TfSpan<const SdfPath> paths)
TRACE_FUNCTION();

_PathIndexMap pathMap;
for (ptrdiff_t i = 0; i < paths.size(); ++i) {
for (size_t i = 0; i < paths.size(); ++i) {
pathMap[paths[i]] = static_cast<int>(i);
}

VtIntArray parentIndices;
parentIndices.assign(paths.size(), -1);

const auto parentIndicesSpan = TfMakeSpan(parentIndices);
for (ptrdiff_t i = 0; i < paths.size(); ++i) {
for (size_t i = 0; i < paths.size(); ++i) {
parentIndicesSpan[i] = _GetParentIndex(pathMap, paths[i]);
}
return parentIndices;
Expand All @@ -99,7 +99,7 @@ _ComputeParentIndicesFromTokens(TfSpan<const TfToken> tokens)
{
// Convert tokens to paths.
SdfPathVector paths(tokens.size());
for (ptrdiff_t i = 0; i < tokens.size(); ++i) {
for (size_t i = 0; i < tokens.size(); ++i) {
paths[i] = SdfPath(tokens[i].GetString());
}
return _ComputeParentIndicesFromPaths(paths);
Expand Down
Loading

0 comments on commit 5ad0b2f

Please sign in to comment.