@@ -486,7 +486,7 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {
486
486
write_js_callback, dictionary, dictionary_len);
487
487
if (!ret) goto end;
488
488
489
- SetDictionary (ctx );
489
+ ctx-> SetDictionary ();
490
490
491
491
end:
492
492
return args.GetReturnValue ().Set (ret);
@@ -496,14 +496,14 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {
496
496
CHECK (args.Length () == 2 && " params(level, strategy)" );
497
497
ZCtx* ctx;
498
498
ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Holder ());
499
- Params (ctx, args[0 ]->Int32Value (), args[1 ]->Int32Value ());
499
+ ctx-> Params (args[0 ]->Int32Value (), args[1 ]->Int32Value ());
500
500
}
501
501
502
502
static void Reset (const FunctionCallbackInfo<Value> &args) {
503
503
ZCtx* ctx;
504
504
ASSIGN_OR_RETURN_UNWRAP (&ctx, args.Holder ());
505
505
ctx->Reset ();
506
- SetDictionary (ctx );
506
+ ctx-> SetDictionary ();
507
507
}
508
508
509
509
static bool Init (ZCtx* ctx, int level, int windowBits, int memLevel,
@@ -577,51 +577,47 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {
577
577
return true ;
578
578
}
579
579
580
- static void SetDictionary (ZCtx* ctx ) {
581
- if (ctx-> dictionary_ == nullptr )
580
+ void SetDictionary () {
581
+ if (dictionary_ == nullptr )
582
582
return ;
583
583
584
- ctx-> err_ = Z_OK;
584
+ err_ = Z_OK;
585
585
586
- switch (ctx-> mode_ ) {
586
+ switch (mode_) {
587
587
case DEFLATE:
588
588
case DEFLATERAW:
589
- ctx->err_ = deflateSetDictionary (&ctx->strm_ ,
590
- ctx->dictionary_ ,
591
- ctx->dictionary_len_ );
589
+ err_ = deflateSetDictionary (&strm_, dictionary_, dictionary_len_);
592
590
break ;
593
591
case INFLATERAW:
594
592
// The other inflate cases will have the dictionary set when inflate()
595
593
// returns Z_NEED_DICT in Process()
596
- ctx->err_ = inflateSetDictionary (&ctx->strm_ ,
597
- ctx->dictionary_ ,
598
- ctx->dictionary_len_ );
594
+ err_ = inflateSetDictionary (&strm_, dictionary_, dictionary_len_);
599
595
break ;
600
596
default :
601
597
break ;
602
598
}
603
599
604
- if (ctx-> err_ != Z_OK) {
605
- ctx-> Error (" Failed to set dictionary" );
600
+ if (err_ != Z_OK) {
601
+ Error (" Failed to set dictionary" );
606
602
}
607
603
}
608
604
609
- static void Params (ZCtx* ctx, int level, int strategy) {
610
- AllocScope alloc_scope (ctx );
605
+ void Params (int level, int strategy) {
606
+ AllocScope alloc_scope (this );
611
607
612
- ctx-> err_ = Z_OK;
608
+ err_ = Z_OK;
613
609
614
- switch (ctx-> mode_ ) {
610
+ switch (mode_) {
615
611
case DEFLATE:
616
612
case DEFLATERAW:
617
- ctx-> err_ = deflateParams (&ctx-> strm_ , level, strategy);
613
+ err_ = deflateParams (&strm_, level, strategy);
618
614
break ;
619
615
default :
620
616
break ;
621
617
}
622
618
623
- if (ctx-> err_ != Z_OK && ctx-> err_ != Z_BUF_ERROR) {
624
- ctx-> Error (" Failed to set parameters" );
619
+ if (err_ != Z_OK && err_ != Z_BUF_ERROR) {
620
+ Error (" Failed to set parameters" );
625
621
}
626
622
}
627
623
0 commit comments