Skip to content

Commit 27ead1e

Browse files
committed
perf_hooks: format cpp
1 parent a40da0a commit 27ead1e

3 files changed

Lines changed: 30 additions & 49 deletions

File tree

src/histogram.cc

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ CFunction IntervalHistogram::fast_start_(
6868
CFunction::Make(&IntervalHistogram::FastStart));
6969
CFunction IntervalHistogram::fast_stop_(
7070
CFunction::Make(&IntervalHistogram::FastStop));
71-
CFunction ELDHistogram::fast_start_(
72-
CFunction::Make(&ELDHistogram::FastStart));
73-
CFunction ELDHistogram::fast_stop_(
74-
CFunction::Make(&ELDHistogram::FastStop));
71+
CFunction ELDHistogram::fast_start_(CFunction::Make(&ELDHistogram::FastStart));
72+
CFunction ELDHistogram::fast_stop_(CFunction::Make(&ELDHistogram::FastStop));
7573

7674
void HistogramImpl::AddMethods(Isolate* isolate, Local<FunctionTemplate> tmpl) {
7775
// TODO(@jasnell): The bigint API variations do not yet support fast
@@ -448,8 +446,7 @@ void IntervalHistogram::FastStop(Local<Value> receiver) {
448446
histogram->OnStop();
449447
}
450448

451-
Local<FunctionTemplate> ELDHistogram::GetConstructorTemplate(
452-
Environment* env) {
449+
Local<FunctionTemplate> ELDHistogram::GetConstructorTemplate(Environment* env) {
453450
Local<FunctionTemplate> tmpl = env->eldhistogram_constructor_template();
454451
if (tmpl.IsEmpty()) {
455452
Isolate* isolate = env->isolate();
@@ -475,16 +472,12 @@ void ELDHistogram::RegisterExternalReferences(
475472
HistogramImpl::RegisterExternalReferences(registry);
476473
}
477474

478-
ELDHistogram::ELDHistogram(
479-
Environment* env,
480-
Local<Object> wrap,
481-
AsyncWrap::ProviderType type,
482-
const Histogram::Options& options)
475+
ELDHistogram::ELDHistogram(Environment* env,
476+
Local<Object> wrap,
477+
AsyncWrap::ProviderType type,
478+
const Histogram::Options& options)
483479
: HandleWrap(
484-
env,
485-
wrap,
486-
reinterpret_cast<uv_handle_t*>(&check_handle_),
487-
type),
480+
env, wrap, reinterpret_cast<uv_handle_t*>(&check_handle_), type),
488481
HistogramImpl(options) {
489482
MakeWeak();
490483
wrap->SetAlignedPointerInInternalField(
@@ -499,20 +492,17 @@ ELDHistogram::ELDHistogram(
499492
}
500493

501494
BaseObjectPtr<ELDHistogram> ELDHistogram::Create(
502-
Environment* env,
503-
const Histogram::Options& options) {
495+
Environment* env, const Histogram::Options& options) {
504496
Local<Object> obj;
505497
if (!GetConstructorTemplate(env)
506-
->InstanceTemplate()
507-
->NewInstance(env->context()).ToLocal(&obj)) {
498+
->InstanceTemplate()
499+
->NewInstance(env->context())
500+
.ToLocal(&obj)) {
508501
return nullptr;
509502
}
510503

511504
return MakeBaseObject<ELDHistogram>(
512-
env,
513-
obj,
514-
AsyncWrap::PROVIDER_ELDHISTOGRAM,
515-
options);
505+
env, obj, AsyncWrap::PROVIDER_ELDHISTOGRAM, options);
516506
}
517507

518508
void ELDHistogram::PrepareCB(uv_prepare_t* handle) {
@@ -523,8 +513,7 @@ void ELDHistogram::PrepareCB(uv_prepare_t* handle) {
523513
}
524514

525515
void ELDHistogram::CheckCB(uv_check_t* handle) {
526-
ELDHistogram* self =
527-
ContainerOf(&ELDHistogram::check_handle_, handle);
516+
ELDHistogram* self = ContainerOf(&ELDHistogram::check_handle_, handle);
528517
if (!self->enabled_) return;
529518

530519
uint64_t check_time = uv_hrtime();
@@ -549,8 +538,7 @@ void ELDHistogram::MemoryInfo(MemoryTracker* tracker) const {
549538
void ELDHistogram::OnStart(StartFlags flags) {
550539
if (enabled_ || IsHandleClosing()) return;
551540
enabled_ = true;
552-
if (flags == StartFlags::RESET)
553-
histogram()->Reset();
541+
if (flags == StartFlags::RESET) histogram()->Reset();
554542
check_time_ = uv_hrtime();
555543
prepare_time_ = check_time_;
556544
timeout_ = 0;
@@ -580,13 +568,12 @@ void ELDHistogram::Close(Local<Value> close_callback) {
580568

581569
if (!close_callback.IsEmpty() && close_callback->IsFunction() &&
582570
!persistent().IsEmpty()) {
583-
object()->Set(env()->context(),
584-
env()->handle_onclose_symbol(),
585-
close_callback).Check();
571+
object()
572+
->Set(env()->context(), env()->handle_onclose_symbol(), close_callback)
573+
.Check();
586574
}
587575

588-
uv_close(reinterpret_cast<uv_handle_t*>(&prepare_handle_),
589-
PrepareCloseCB);
576+
uv_close(reinterpret_cast<uv_handle_t*>(&prepare_handle_), PrepareCloseCB);
590577
}
591578

592579
void ELDHistogram::Start(const FunctionCallbackInfo<Value>& args) {
@@ -778,8 +765,7 @@ HistogramImpl* HistogramImpl::FromJSObject(Local<Value> value) {
778765
HistogramImpl::kImplField, EmbedderDataTag::kDefault));
779766
}
780767

781-
std::unique_ptr<worker::TransferData>
782-
ELDHistogram::CloneForMessaging() const {
768+
std::unique_ptr<worker::TransferData> ELDHistogram::CloneForMessaging() const {
783769
return std::make_unique<HistogramBase::HistogramTransferData>(histogram());
784770
}
785771

src/histogram.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,25 +273,20 @@ class ELDHistogram final : public HandleWrap, public HistogramImpl {
273273
HandleWrap::kInternalFieldCount, HistogramImpl::kInternalFieldCount),
274274
};
275275

276-
enum class StartFlags {
277-
NONE,
278-
RESET
279-
};
276+
enum class StartFlags { NONE, RESET };
280277

281278
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
282279

283280
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
284281
Environment* env);
285282

286-
static BaseObjectPtr<ELDHistogram> Create(
287-
Environment* env,
288-
const Histogram::Options& options);
283+
static BaseObjectPtr<ELDHistogram> Create(Environment* env,
284+
const Histogram::Options& options);
289285

290-
ELDHistogram(
291-
Environment* env,
292-
v8::Local<v8::Object> wrap,
293-
AsyncWrap::ProviderType type,
294-
const Histogram::Options& options = Histogram::Options {});
286+
ELDHistogram(Environment* env,
287+
v8::Local<v8::Object> wrap,
288+
AsyncWrap::ProviderType type,
289+
const Histogram::Options& options = Histogram::Options{});
295290

296291
static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
297292
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -304,8 +299,8 @@ class ELDHistogram final : public HandleWrap, public HistogramImpl {
304299
}
305300
std::unique_ptr<worker::TransferData> CloneForMessaging() const override;
306301

307-
void Close(v8::Local<v8::Value> close_callback =
308-
v8::Local<v8::Value>()) override;
302+
void Close(
303+
v8::Local<v8::Value> close_callback = v8::Local<v8::Value>()) override;
309304

310305
void MemoryInfo(MemoryTracker* tracker) const override;
311306
SET_MEMORY_INFO_NAME(ELDHistogram)

src/node_perf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ void CreateELDHistogram(const FunctionCallbackInfo<Value>& args) {
284284
CHECK_GT(interval, 0);
285285
if (args[1]->IsTrue()) {
286286
BaseObjectPtr<ELDHistogram> histogram =
287-
ELDHistogram::Create(env, Histogram::Options { 1 });
287+
ELDHistogram::Create(env, Histogram::Options{1});
288288
args.GetReturnValue().Set(histogram->object());
289289
return;
290290
}

0 commit comments

Comments
 (0)