Remove static from template functions in headers.

When static is used, this triggers a warning which we currently have
disabled, -Wunused-template ("unused function template SkTAfter").

There doesn't seem to be any benefit to adding static here. See
https://stackoverflow.com/a/30863380/291737 for a brief explanation.

Unfortunately this doesn't quite allow us to enable the warning, as
we have some static member functions that also trigger the warning.

Change-Id: I7198bdc1bff2bdd5a090ee2b2d5520baa5e4b9e9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/505300
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2022-02-08 11:56:46 -05:00 committed by SkCQ
parent f7db39f59d
commit 3bb1f9db82
5 changed files with 9 additions and 9 deletions

View File

@ -35,14 +35,14 @@ template<typename T> inline void sk_ignore_unused_variable(const T&) { }
/**
* Returns a pointer to a D which comes immediately after S[count].
*/
template <typename D, typename S> static D* SkTAfter(S* ptr, size_t count = 1) {
template <typename D, typename S> inline D* SkTAfter(S* ptr, size_t count = 1) {
return reinterpret_cast<D*>(ptr + count);
}
/**
* Returns a pointer to a D which comes byteOffset bytes after S.
*/
template <typename D, typename S> static D* SkTAddOffset(S* ptr, ptrdiff_t byteOffset) {
template <typename D, typename S> inline D* SkTAddOffset(S* ptr, ptrdiff_t byteOffset) {
// The intermediate char* has the same cv-ness as D as this produces better error messages.
// This relies on the fact that reinterpret_cast can add constness, but cannot remove it.
return reinterpret_cast<D*>(reinterpret_cast<sknonstd::same_cv_t<char, D>*>(ptr) + byteOffset);

View File

@ -56,7 +56,7 @@ static inline void insert_edge_after(EdgeType* edge, EdgeType* afterMe) {
}
template<class EdgeType>
static void backward_insert_edge_based_on_x(EdgeType* edge) {
void backward_insert_edge_based_on_x(EdgeType* edge) {
SkFixed x = edge->fX;
EdgeType* prev = edge->fPrev;
while (prev->fPrev && prev->fX > x) {
@ -73,7 +73,7 @@ static void backward_insert_edge_based_on_x(EdgeType* edge) {
// of the prior insertion, and search to the right, or with some additional caching, binary
// search the starting point. More work could be done to determine optimal new edge insertion.
template<class EdgeType>
static EdgeType* backward_insert_start(EdgeType* prev, SkFixed x) {
EdgeType* backward_insert_start(EdgeType* prev, SkFixed x) {
while (prev->fPrev && prev->fX > x) {
prev = prev->fPrev;
}

View File

@ -111,7 +111,7 @@ template <typename T> void SkTHeapSort(T array[], size_t count) {
/** Sorts the array of size count using comparator lessThan using an Insertion Sort algorithm. */
template <typename T, typename C>
static void SkTInsertionSort(T* left, int count, const C& lessThan) {
void SkTInsertionSort(T* left, int count, const C& lessThan) {
T* right = left + count - 1;
for (T* next = left + 1; next <= right; ++next) {
if (!lessThan(*next, *(next - 1))) {
@ -130,7 +130,7 @@ static void SkTInsertionSort(T* left, int count, const C& lessThan) {
///////////////////////////////////////////////////////////////////////////////
template <typename T, typename C>
static T* SkTQSort_Partition(T* left, int count, T* pivot, const C& lessThan) {
T* SkTQSort_Partition(T* left, int count, T* pivot, const C& lessThan) {
T* right = left + count - 1;
using std::swap;
T pivotValue = *pivot;

View File

@ -123,7 +123,7 @@ void GetCustomFontFamilies(SkTDArray<FontFamily*>& fontFamilies,
*
* If the string cannot be parsed into 'value', returns false and does not change 'value'.
*/
template <typename T> static bool parse_non_negative_integer(const char* s, T* value) {
template <typename T> bool parse_non_negative_integer(const char* s, T* value) {
static_assert(std::numeric_limits<T>::is_integer, "T_must_be_integer");
if (*s == '\0') {
@ -160,7 +160,7 @@ template <typename T> static bool parse_non_negative_integer(const char* s, T* v
*
* If the string cannot be parsed into 'value', returns false and does not change 'value'.
*/
template <int N, typename T> static bool parse_fixed(const char* s, T* value) {
template <int N, typename T> bool parse_fixed(const char* s, T* value) {
static_assert(std::numeric_limits<T>::is_integer, "T_must_be_integer");
static_assert(std::numeric_limits<T>::is_signed, "T_must_be_signed");
static_assert(sizeof(T) * CHAR_BIT - N >= 5, "N_must_leave_four_bits_plus_sign");

View File

@ -158,7 +158,7 @@ typedef SkTArray<DiffRecord> RecordArray;
/// A wrapper for any sortProc (comparison routine) which applies a first-order
/// sort beforehand, and a tiebreaker if the sortProc returns 0.
template<typename T> static int compare(const void* untyped_lhs, const void* untyped_rhs) {
template<typename T> int compare(const void* untyped_lhs, const void* untyped_rhs) {
const DiffRecord* lhs = reinterpret_cast<DiffRecord const *>(untyped_lhs);
const DiffRecord* rhs = reinterpret_cast<DiffRecord const *>(untyped_rhs);