2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Use ranges:: algorithms instead of base::

This commit is contained in:
John Preston
2017-11-20 16:23:20 +04:00
parent bc7c88c511
commit ac99318f34
28 changed files with 751 additions and 596 deletions

View File

@@ -60,7 +60,8 @@ private:
};
UserPhotosSlice::UserPhotosSlice(Key key) : UserPhotosSlice(
UserPhotosSlice::UserPhotosSlice(Key key)
: UserPhotosSlice(
key,
{},
base::none,
@@ -74,15 +75,15 @@ UserPhotosSlice::UserPhotosSlice(
base::optional<int> fullCount,
base::optional<int> skippedBefore,
int skippedAfter)
: _key(key)
, _ids(ids)
, _fullCount(fullCount)
, _skippedBefore(skippedBefore)
, _skippedAfter(skippedAfter) {
: _key(key)
, _ids(ids)
, _fullCount(fullCount)
, _skippedBefore(skippedBefore)
, _skippedAfter(skippedAfter) {
}
base::optional<int> UserPhotosSlice::indexOf(PhotoId photoId) const {
auto it = base::find(_ids, photoId);
auto it = ranges::find(_ids, photoId);
if (it != _ids.end()) {
return (it - _ids.begin());
}
@@ -190,7 +191,7 @@ void UserPhotosSliceBuilder::mergeSliceData(
}
void UserPhotosSliceBuilder::sliceToLimits() {
auto aroundIt = base::find(_ids, _key.photoId);
auto aroundIt = ranges::find(_ids, _key.photoId);
auto removeFromBegin = (aroundIt - _ids.begin() - _limitBefore);
auto removeFromEnd = (_ids.end() - aroundIt - _limitAfter - 1);
if (removeFromEnd > 0) {