| 755 | } |
| 756 | |
| 757 | void StringFunctions::DoTrimPrepare(FunctionContext* context, |
| 758 | FunctionContext::FunctionStateScope scope, bool utf8_mode) { |
| 759 | if (scope != FunctionContext::THREAD_LOCAL) return; |
| 760 | TrimContext* trim_ctx = new TrimContext(utf8_mode); |
| 761 | context->SetFunctionState(scope, trim_ctx); |
| 762 | |
| 763 | // If the caller didn't specify the set of characters to trim, it means |
| 764 | // that we're only trimming whitespace. Return early in that case. |
| 765 | // There can be either 1 or 2 arguments. |
| 766 | DCHECK(context->GetNumArgs() == 1 || context->GetNumArgs() == 2); |
| 767 | if (context->GetNumArgs() == 1) { |
| 768 | trim_ctx->Reset(StringVal(" ")); |
| 769 | return; |
| 770 | } |
| 771 | if (!context->IsArgConstant(1)) return; |
| 772 | DCHECK_EQ(context->GetArgType(1)->type, FunctionContext::TYPE_STRING); |
| 773 | StringVal* chars_to_trim = reinterpret_cast<StringVal*>(context->GetConstantArg(1)); |
| 774 | if (chars_to_trim->is_null) return; // We shouldn't peek into Null StringVals |
| 775 | trim_ctx->Reset(*chars_to_trim); |
| 776 | } |
| 777 | |
| 778 | void StringFunctions::TrimClose( |
| 779 | FunctionContext* context, FunctionContext::FunctionStateScope scope) { |
nothing calls this directly
no test coverage detected