Skip to content

Commit f948956

Browse files
committed
Use td::unique_ptr instead of std::unique_ptr whenever possible.
GitOrigin-RevId: 424beb72dc62efdefdbffb75f1036ba9417f84cb
1 parent 83be04a commit f948956

139 files changed

Lines changed: 541 additions & 541 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎benchmark/bench_actor.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class QueryBench : public td::Benchmark {
136136
virtual ~Callback() = default;
137137
virtual void on_result(int x) = 0;
138138
};
139-
explicit ClientActor(std::unique_ptr<Callback> callback) : callback_(std::move(callback)) {
139+
explicit ClientActor(td::unique_ptr<Callback> callback) : callback_(std::move(callback)) {
140140
}
141141
void f(int x) {
142142
callback_->on_result(x * x);
@@ -152,7 +152,7 @@ class QueryBench : public td::Benchmark {
152152
}
153153

154154
private:
155-
std::unique_ptr<Callback> callback_;
155+
td::unique_ptr<Callback> callback_;
156156
};
157157

158158
class ServerActor : public td::Actor {

‎benchmark/bench_db.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ class SqliteKeyValueAsyncBench : public td::Benchmark {
167167
}
168168

169169
private:
170-
std::unique_ptr<td::ConcurrentScheduler> scheduler_;
170+
td::unique_ptr<td::ConcurrentScheduler> scheduler_;
171171
std::shared_ptr<td::SqliteConnectionSafe> sql_connection_;
172172
std::shared_ptr<td::SqliteKeyValueSafe> sqlite_kv_safe_;
173-
std::unique_ptr<td::SqliteKeyValueAsyncInterface> sqlite_kv_async_;
173+
td::unique_ptr<td::SqliteKeyValueAsyncInterface> sqlite_kv_async_;
174174

175175
td::Status do_start_up() {
176-
scheduler_ = std::make_unique<td::ConcurrentScheduler>();
176+
scheduler_ = td::make_unique<td::ConcurrentScheduler>();
177177
scheduler_->init(1);
178178

179179
auto guard = scheduler_->get_main_guard();

‎benchmark/bench_tddb.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ class MessagesDbBench : public Benchmark {
7676
}
7777

7878
private:
79-
std::unique_ptr<td::ConcurrentScheduler> scheduler_;
79+
td::unique_ptr<td::ConcurrentScheduler> scheduler_;
8080
std::shared_ptr<SqliteConnectionSafe> sql_connection_;
8181
std::shared_ptr<MessagesDbSyncSafeInterface> messages_db_sync_safe_;
8282
std::shared_ptr<MessagesDbAsyncInterface> messages_db_async_;
8383

8484
Status do_start_up() {
85-
scheduler_ = std::make_unique<ConcurrentScheduler>();
85+
scheduler_ = make_unique<ConcurrentScheduler>();
8686
scheduler_->init(1);
8787

8888
auto guard = scheduler_->get_main_guard();

‎benchmark/wget.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
2525
auto timeout = 10;
2626
auto ttl = 3;
2727
auto prefer_ipv6 = (argc > 2 && std::string(argv[2]) == "-6");
28-
auto scheduler = std::make_unique<td::ConcurrentScheduler>();
28+
auto scheduler = td::make_unique<td::ConcurrentScheduler>();
2929
scheduler->init(0);
3030
scheduler
3131
->create_actor_unsafe<td::Wget>(0, "Client", td::PromiseCreator::lambda([](td::Result<td::HttpQueryPtr> res) {

‎example/cpp/td_example.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <iostream>
1515
#include <limits>
1616
#include <map>
17+
#include <memory>
1718
#include <sstream>
1819
#include <string>
1920
#include <vector>

‎td/mtproto/HandshakeActor.cpp‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
66
//
77
#include "td/mtproto/HandshakeActor.h"
8+
89
#include "td/mtproto/HandshakeConnection.h"
910

1011
#include "td/utils/common.h"
@@ -13,14 +14,12 @@
1314

1415
namespace td {
1516
namespace mtproto {
16-
HandshakeActor::HandshakeActor(std::unique_ptr<AuthKeyHandshake> handshake,
17-
std::unique_ptr<RawConnection> raw_connection,
18-
std::unique_ptr<AuthKeyHandshakeContext> context, double timeout,
19-
Promise<std::unique_ptr<RawConnection>> raw_connection_promise,
20-
Promise<std::unique_ptr<AuthKeyHandshake>> handshake_promise)
17+
HandshakeActor::HandshakeActor(unique_ptr<AuthKeyHandshake> handshake, unique_ptr<RawConnection> raw_connection,
18+
unique_ptr<AuthKeyHandshakeContext> context, double timeout,
19+
Promise<unique_ptr<RawConnection>> raw_connection_promise,
20+
Promise<unique_ptr<AuthKeyHandshake>> handshake_promise)
2121
: handshake_(std::move(handshake))
22-
, connection_(
23-
std::make_unique<HandshakeConnection>(std::move(raw_connection), handshake_.get(), std::move(context)))
22+
, connection_(make_unique<HandshakeConnection>(std::move(raw_connection), handshake_.get(), std::move(context)))
2423
, timeout_(timeout)
2524
, raw_connection_promise_(std::move(raw_connection_promise))
2625
, handshake_promise_(std::move(handshake_promise)) {

‎td/mtproto/HandshakeActor.h‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,28 @@
1313

1414
namespace td {
1515
namespace mtproto {
16+
1617
class AuthKeyHandshake;
1718
class AuthKeyHandshakeContext;
1819
class RawConnection;
1920
class HandshakeConnection;
21+
2022
// Has Raw connection. Generates new auth key. And returns it and raw_connection. Or error...
2123
class HandshakeActor : public Actor {
2224
public:
23-
HandshakeActor(std::unique_ptr<AuthKeyHandshake> handshake, std::unique_ptr<RawConnection> raw_connection,
24-
std::unique_ptr<AuthKeyHandshakeContext> context, double timeout,
25-
Promise<std::unique_ptr<RawConnection>> raw_connection_promise,
26-
Promise<std::unique_ptr<AuthKeyHandshake>> handshake_promise);
25+
HandshakeActor(unique_ptr<AuthKeyHandshake> handshake, unique_ptr<RawConnection> raw_connection,
26+
unique_ptr<AuthKeyHandshakeContext> context, double timeout,
27+
Promise<unique_ptr<RawConnection>> raw_connection_promise,
28+
Promise<unique_ptr<AuthKeyHandshake>> handshake_promise);
2729
void close();
2830

2931
private:
30-
std::unique_ptr<AuthKeyHandshake> handshake_;
31-
std::unique_ptr<HandshakeConnection> connection_;
32+
unique_ptr<AuthKeyHandshake> handshake_;
33+
unique_ptr<HandshakeConnection> connection_;
3234
double timeout_;
3335

34-
Promise<std::unique_ptr<RawConnection>> raw_connection_promise_;
35-
Promise<std::unique_ptr<AuthKeyHandshake>> handshake_promise_;
36+
Promise<unique_ptr<RawConnection>> raw_connection_promise_;
37+
Promise<unique_ptr<AuthKeyHandshake>> handshake_promise_;
3638

3739
void start_up() override;
3840
void tear_down() override {

‎td/mtproto/HandshakeConnection.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class HandshakeConnection
2626
: private RawConnection::Callback
2727
, private AuthKeyHandshake::Callback {
2828
public:
29-
HandshakeConnection(std::unique_ptr<RawConnection> raw_connection, AuthKeyHandshake *handshake,
30-
std::unique_ptr<AuthKeyHandshakeContext> context)
29+
HandshakeConnection(unique_ptr<RawConnection> raw_connection, AuthKeyHandshake *handshake,
30+
unique_ptr<AuthKeyHandshakeContext> context)
3131
: raw_connection_(std::move(raw_connection)), handshake_(handshake), context_(std::move(context)) {
3232
handshake_->resume(this);
3333
}
@@ -36,7 +36,7 @@ class HandshakeConnection
3636
return raw_connection_->get_poll_info();
3737
}
3838

39-
std::unique_ptr<RawConnection> move_as_raw_connection() {
39+
unique_ptr<RawConnection> move_as_raw_connection() {
4040
return std::move(raw_connection_);
4141
}
4242

@@ -54,9 +54,9 @@ class HandshakeConnection
5454
}
5555

5656
private:
57-
std::unique_ptr<RawConnection> raw_connection_;
57+
unique_ptr<RawConnection> raw_connection_;
5858
AuthKeyHandshake *handshake_;
59-
std::unique_ptr<AuthKeyHandshakeContext> context_;
59+
unique_ptr<AuthKeyHandshakeContext> context_;
6060

6161
void send_no_crypto(const Storer &storer) override {
6262
raw_connection_->send_no_crypto(PacketStorer<NoCryptoImpl>(0, storer));

‎td/mtproto/IStreamTransport.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
namespace td {
1515
namespace mtproto {
16-
std::unique_ptr<IStreamTransport> create_transport(TransportType type) {
16+
unique_ptr<IStreamTransport> create_transport(TransportType type) {
1717
switch (type.type) {
1818
case TransportType::ObfuscatedTcp:
19-
return std::make_unique<tcp::ObfuscatedTransport>(type.dc_id, std::move(type.secret));
19+
return td::make_unique<tcp::ObfuscatedTransport>(type.dc_id, std::move(type.secret));
2020
case TransportType::Tcp:
21-
return std::make_unique<tcp::OldTransport>();
21+
return td::make_unique<tcp::OldTransport>();
2222
case TransportType::Http:
23-
return std::make_unique<http::Transport>(type.secret);
23+
return td::make_unique<http::Transport>(type.secret);
2424
}
2525
UNREACHABLE();
2626
}

‎td/mtproto/IStreamTransport.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ class IStreamTransport {
3434
virtual TransportType get_type() const = 0;
3535
};
3636

37-
std::unique_ptr<IStreamTransport> create_transport(TransportType type);
37+
unique_ptr<IStreamTransport> create_transport(TransportType type);
3838
} // namespace mtproto
3939
} // namespace td

0 commit comments

Comments
 (0)