Moved out generating unique PeerListRowId from string to single place.
This commit is contained in:
		
							parent
							
								
									1851b6ff30
								
							
						
					
					
						commit
						1852161fbf
					
				
					 4 changed files with 12 additions and 19 deletions
				
			
		| 
						 | 
					@ -37,8 +37,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
#include "styles/style_menu_icons.h"
 | 
					#include "styles/style_menu_icons.h"
 | 
				
			||||||
#include "styles/style_settings.h"
 | 
					#include "styles/style_settings.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <xxhash.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace {
 | 
					namespace {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
constexpr auto kMaxLinkTitleLength = 32;
 | 
					constexpr auto kMaxLinkTitleLength = 32;
 | 
				
			||||||
| 
						 | 
					@ -223,14 +221,6 @@ private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] uint64 ComputeRowId(const QString &link) {
 | 
					 | 
				
			||||||
	return XXH64(link.data(), link.size() * sizeof(ushort), 0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[[nodiscard]] uint64 ComputeRowId(const InviteLinkData &data) {
 | 
					 | 
				
			||||||
	return ComputeRowId(data.url);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[[nodiscard]] Color ComputeColor(const InviteLinkData &link) {
 | 
					[[nodiscard]] Color ComputeColor(const InviteLinkData &link) {
 | 
				
			||||||
	return Color::Permanent;
 | 
						return Color::Permanent;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -242,7 +232,7 @@ private:
 | 
				
			||||||
LinkRow::LinkRow(
 | 
					LinkRow::LinkRow(
 | 
				
			||||||
	not_null<LinkRowDelegate*> delegate,
 | 
						not_null<LinkRowDelegate*> delegate,
 | 
				
			||||||
	const InviteLinkData &data)
 | 
						const InviteLinkData &data)
 | 
				
			||||||
: PeerListRow(ComputeRowId(data))
 | 
					: PeerListRow(UniqueRowIdFromString(data.url))
 | 
				
			||||||
, _delegate(delegate)
 | 
					, _delegate(delegate)
 | 
				
			||||||
, _data(data)
 | 
					, _data(data)
 | 
				
			||||||
, _color(ComputeColor(data)) {
 | 
					, _color(ComputeColor(data)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
#include "styles/style_dialogs.h"
 | 
					#include "styles/style_dialogs.h"
 | 
				
			||||||
#include "styles/style_widgets.h"
 | 
					#include "styles/style_widgets.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <xxhash.h> // XXH64.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[nodiscard]] PeerListRowId UniqueRowIdFromString(const QString &d) {
 | 
				
			||||||
 | 
						return XXH64(d.data(), d.size() * sizeof(ushort), 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PaintRoundImageCallback PaintUserpicCallback(
 | 
					PaintRoundImageCallback PaintUserpicCallback(
 | 
				
			||||||
		not_null<PeerData*> peer,
 | 
							not_null<PeerData*> peer,
 | 
				
			||||||
		bool respectSavedMessagesChat) {
 | 
							bool respectSavedMessagesChat) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,6 +54,8 @@ using PaintRoundImageCallback = Fn<void(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using PeerListRowId = uint64;
 | 
					using PeerListRowId = uint64;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[nodiscard]] PeerListRowId UniqueRowIdFromString(const QString &d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PeerListRow {
 | 
					class PeerListRow {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	enum class State {
 | 
						enum class State {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,8 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
#include "styles/style_settings.h" // st::settingsDividerLabelPadding
 | 
					#include "styles/style_settings.h" // st::settingsDividerLabelPadding
 | 
				
			||||||
#include "styles/style_menu_icons.h"
 | 
					#include "styles/style_menu_icons.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <xxhash.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace {
 | 
					namespace {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum class Color {
 | 
					enum class Color {
 | 
				
			||||||
| 
						 | 
					@ -112,12 +110,8 @@ private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] uint64 ComputeRowId(const QString &link) {
 | 
					 | 
				
			||||||
	return XXH64(link.data(), link.size() * sizeof(ushort), 0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[[nodiscard]] uint64 ComputeRowId(const InviteLinkData &data) {
 | 
					[[nodiscard]] uint64 ComputeRowId(const InviteLinkData &data) {
 | 
				
			||||||
	return ComputeRowId(data.link);
 | 
						return UniqueRowIdFromString(data.link);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] float64 ComputeProgress(
 | 
					[[nodiscard]] float64 ComputeProgress(
 | 
				
			||||||
| 
						 | 
					@ -628,7 +622,8 @@ void LinksController::updateRow(const InviteLinkData &data, TimeId now) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool LinksController::removeRow(const QString &link) {
 | 
					bool LinksController::removeRow(const QString &link) {
 | 
				
			||||||
	if (const auto row = delegate()->peerListFindRow(ComputeRowId(link))) {
 | 
						const auto id = UniqueRowIdFromString(link);
 | 
				
			||||||
 | 
						if (const auto row = delegate()->peerListFindRow(id)) {
 | 
				
			||||||
		delegate()->peerListRemoveRow(row);
 | 
							delegate()->peerListRemoveRow(row);
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue