@@ -425,7 +425,6 @@ class TextBufferSearcher : public Nan::AsyncWorker {
425
425
}
426
426
427
427
void HandleOKCallback () {
428
- delete snapshot;
429
428
Local<Value> argv[] = {Nan::Null (), encode_ranges (matches)};
430
429
callback->Call (2 , argv, async_resource);
431
430
}
@@ -586,7 +585,6 @@ void TextBufferWrapper::find_words_with_subsequence_in_range(const Nan::Function
586
585
void CancelIfQueued () {
587
586
int lock_status = uv_rwlock_trywrlock (&snapshot_lock);
588
587
if (lock_status == 0 ) {
589
- delete snapshot;
590
588
snapshot = nullptr ;
591
589
uv_rwlock_wrunlock (&snapshot_lock);
592
590
}
@@ -599,7 +597,6 @@ void TextBufferWrapper::find_words_with_subsequence_in_range(const Nan::Function
599
597
return ;
600
598
}
601
599
602
- delete snapshot;
603
600
auto text_buffer_wrapper = Nan::ObjectWrap::Unwrap<TextBufferWrapper>(Nan::New (buffer));
604
601
text_buffer_wrapper->outstanding_workers .erase (this );
605
602
@@ -730,7 +727,7 @@ class Loader {
730
727
Nan::Callback *progress_callback;
731
728
Nan::AsyncResource *async_resource;
732
729
TextBuffer *buffer;
733
- TextBuffer::Snapshot * snapshot;
730
+ std::shared_ptr< TextBuffer::Snapshot> snapshot;
734
731
string file_name;
735
732
string encoding_name;
736
733
optional<Text> loaded_text;
@@ -778,17 +775,14 @@ class Loader {
778
775
779
776
pair<Local<Value>, Local<Value>> Finish (Nan::AsyncResource* caller_async_resource = nullptr ) {
780
777
if (error) {
781
- delete snapshot;
782
778
return {error_to_js (*error, encoding_name, file_name), Nan::Undefined ()};
783
779
}
784
780
785
781
if (cancelled || (!force && buffer->is_modified ())) {
786
- delete snapshot;
787
782
return {Nan::Null (), Nan::Null ()};
788
783
}
789
784
790
785
Patch inverted_changes = buffer->get_inverted_changes (snapshot);
791
- delete snapshot;
792
786
793
787
if (compute_patch && inverted_changes.get_change_count () > 0 ) {
794
788
inverted_changes.combine (patch);
@@ -1004,7 +998,6 @@ class BaseTextComparisonWorker : public Nan::AsyncWorker {
1004
998
}
1005
999
1006
1000
void HandleOKCallback () {
1007
- delete snapshot;
1008
1001
if (error) {
1009
1002
Local<Value> argv[] = {error_to_js (*error, encoding_name, file_name)};
1010
1003
callback->Call (1 , argv, async_resource);
@@ -1090,11 +1083,9 @@ class SaveWorker : public Nan::AsyncWorker {
1090
1083
1091
1084
Local<Value> Finish () {
1092
1085
if (error) {
1093
- delete snapshot;
1094
1086
return error_to_js (*error, encoding_name, file_name);
1095
1087
} else {
1096
1088
snapshot->flush_preceding_changes ();
1097
- delete snapshot;
1098
1089
return Nan::Null ();
1099
1090
}
1100
1091
}
0 commit comments