| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3db2206 commit f08e2e0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ const searchStrings = [ | |||
| 19 | 19 | ||
| 20 | 20 | const bench = common.createBenchmark(main, { | |
| 21 | 21 | search: searchStrings, | |
| 22 | - encoding: ['undefined', 'utf8', 'ucs2'], | ||
| 22 | + encoding: ['undefined', 'utf8', 'ucs2', 'latin1'], | ||
| 23 | 23 | type: ['buffer', 'string'], | |
| 24 | 24 | n: [5e4], | |
| 25 | 25 | }, { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1051,23 +1051,19 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) { | |||
| 1051 | 1051 | offset, | |
| 1052 | 1052 | is_forward); | |
| 1053 | 1053 | } else if (enc == LATIN1) { | |
| 1054 | - uint8_t* needle_data = node::UncheckedMalloc<uint8_t>(needle_length); | ||
| 1055 | - if (needle_data == nullptr) { | ||
| 1056 | - return args.GetReturnValue().Set(-1); | ||
| 1057 | - } | ||
| 1054 | + MaybeStackBuffer<uint8_t> needle_data(needle_length); | ||
| 1058 | 1055 | StringBytes::Write(isolate, | |
| 1059 | - reinterpret_cast<char*>(needle_data), | ||
| 1056 | + reinterpret_cast<char*>(needle_data.out()), | ||
| 1060 | 1057 | needle_length, | |
| 1061 | 1058 | needle, | |
| 1062 | 1059 | enc); | |
| 1063 | 1060 | ||
| 1064 | 1061 | result = nbytes::SearchString(reinterpret_cast<const uint8_t*>(haystack), | |
| 1065 | 1062 | haystack_length, | |
| 1066 | - needle_data, | ||
| 1063 | + needle_data.out(), | ||
| 1067 | 1064 | needle_length, | |
| 1068 | 1065 | offset, | |
| 1069 | 1066 | is_forward); | |
| 1070 | - free(needle_data); | ||
| 1071 | 1067 | } | |
| 1072 | 1068 | ||
| 1073 | 1069 | args.GetReturnValue().Set( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments