Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(927)

Unified Diff: base/numerics/safe_conversions_impl.h

Issue 1164063005: Replace gfx::ClampToInt with base::saturated_cast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/numerics/safe_numerics_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/numerics/safe_conversions_impl.h
diff --git a/base/numerics/safe_conversions_impl.h b/base/numerics/safe_conversions_impl.h
index 504ce7ef29770c7b4f0968b7a8ded5d07f1c2185..37536463168844835f5653472f7b7e6ebf62a542 100644
--- a/base/numerics/safe_conversions_impl.h
+++ b/base/numerics/safe_conversions_impl.h
@@ -148,10 +148,12 @@ struct DstRangeRelationToSrcRangeImpl<Dst,
NUMERIC_RANGE_NOT_CONTAINED> {
static RangeConstraint Check(Src value) {
return std::numeric_limits<Dst>::is_iec559
- ? GetRangeConstraint(value <= std::numeric_limits<Dst>::max(),
- value >= -std::numeric_limits<Dst>::max())
- : GetRangeConstraint(value <= std::numeric_limits<Dst>::max(),
- value >= std::numeric_limits<Dst>::min());
+ ? GetRangeConstraint(
+ value<std::numeric_limits<Dst>::max(), value> -
danakj 2015/06/05 00:19:59 This is some good clang-format mistake here, filin
+ std::numeric_limits<Dst>::max())
+ : GetRangeConstraint(
+ value<std::numeric_limits<Dst>::max(), value>
+ std::numeric_limits<Dst>::min());
}
};
@@ -163,7 +165,7 @@ struct DstRangeRelationToSrcRangeImpl<Dst,
INTEGER_REPRESENTATION_UNSIGNED,
NUMERIC_RANGE_NOT_CONTAINED> {
static RangeConstraint Check(Src value) {
- return GetRangeConstraint(value <= std::numeric_limits<Dst>::max(), true);
+ return GetRangeConstraint(value < std::numeric_limits<Dst>::max(), true);
}
};
@@ -178,7 +180,7 @@ struct DstRangeRelationToSrcRangeImpl<Dst,
return sizeof(Dst) > sizeof(Src)
? RANGE_VALID
: GetRangeConstraint(
- value <= static_cast<Src>(std::numeric_limits<Dst>::max()),
+ value < static_cast<Src>(std::numeric_limits<Dst>::max()),
true);
}
};
@@ -195,7 +197,7 @@ struct DstRangeRelationToSrcRangeImpl<Dst,
return (MaxExponent<Dst>::value >= MaxExponent<Src>::value)
? GetRangeConstraint(true, value >= static_cast<Src>(0))
: GetRangeConstraint(
- value <= static_cast<Src>(std::numeric_limits<Dst>::max()),
+ value < static_cast<Src>(std::numeric_limits<Dst>::max()),
value >= static_cast<Src>(0));
}
};
« no previous file with comments | « no previous file | base/numerics/safe_numerics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698