10X speedup (#2779)

Co-authored-by: pf <pf@me>
pull/2782/head
pfeatherstone 1 year ago committed by GitHub
parent 49ac2eb3ae
commit d41571ea5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

Loading…
Cancel
Save