10X speedup (#2779)

Co-authored-by: pf <pf@me>
This commit is contained in:
pfeatherstone 2023-04-22 04:37:19 +01:00 committed by GitHub
parent 49ac2eb3ae
commit d41571ea5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -49,7 +49,10 @@ namespace dlib
<< "\n\t i: " << i << "\n\t i: " << i
<< "\n\t size(): " << size() << "\n\t size(): " << size()
); );
return data[(i+offset)%data.size()]; auto index = i + offset;
if (index >= data.size())
index -= data.size();
return data[index];
} }
const T& operator[] ( unsigned long i) const const T& operator[] ( unsigned long i) const
@ -61,7 +64,10 @@ namespace dlib
<< "\n\t i: " << i << "\n\t i: " << i
<< "\n\t size(): " << size() << "\n\t size(): " << size()
); );
return data[(i+offset)%data.size()]; auto index = i + offset;
if (index >= data.size())
index -= data.size();
return data[index];
} }
void resize(unsigned long size) void resize(unsigned long size)