Skip to content

Commit 3b11f0e

Browse files
committed
Replace some (str.c_str(), str.length()) uses with std::string& itself
1 parent 95c89fd commit 3b11f0e

File tree

5 files changed

+72
-43
lines changed

5 files changed

+72
-43
lines changed

src/njs/src/njsConnection.cpp

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@ void Connection::GetBinds (Handle<Object> bindobj, eBaton* executeBaton)
665665
Handle<String> temp = array->Get(index).As<String>();
666666
NJSString(str, temp);
667667
bind->key = ":"+std::string(str);
668-
Local<Value> val__ = bindobj->Get(Nan::New<v8::String>((char*)str.c_str(),
669-
(int) str.length()).ToLocalChecked());
668+
Local<Value> val__ = bindobj->Get(
669+
Nan::New<v8::String>(str).ToLocalChecked());
670670
Connection::GetBindUnit(val__, bind, false, executeBaton);
671671
if(!executeBaton->error.empty())
672672
goto exitGetBinds;
@@ -1052,7 +1052,7 @@ void Connection::GetInBindParamsScalar(Local<Value> v8val, Bind* bind,
10521052
* INOUT binds
10531053
*/
10541054
v8::String::Utf8Value str( v8valNULL ?
1055-
Nan::New<v8::String> ( "", 0 ).ToLocalChecked() :
1055+
Nan::New<v8::String> ( "" ).ToLocalChecked() :
10561056
v8val->ToString());
10571057

10581058
bind->type = dpi::DpiVarChar;
@@ -2748,7 +2748,8 @@ void Connection::Async_AfterExecute(uv_work_t *req)
27482748
Local<Value> argv[2];
27492749
if(!(executeBaton->error).empty())
27502750
{
2751-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((executeBaton->error).c_str()).ToLocalChecked());
2751+
argv[0] = v8::Exception::Error(
2752+
Nan::New<v8::String>(executeBaton->error).ToLocalChecked());
27522753
argv[1] = Nan::Undefined();
27532754
}
27542755
else
@@ -2775,22 +2776,25 @@ void Connection::Async_AfterExecute(uv_work_t *req)
27752776
if ( !executeBaton->error.empty () )
27762777
{
27772778
argv[0] = v8::Exception::Error (
2778-
Nan::New<v8::String> (
2779-
(executeBaton->error).c_str()).ToLocalChecked ());
2779+
Nan::New<v8::String> (
2780+
executeBaton->error).ToLocalChecked());
27802781
argv[1] = Nan::Undefined ();
27812782
goto exitAsyncAfterExecute;
27822783
}
27832784

2784-
Nan::Set(result, Nan::New<v8::String>("rows").ToLocalChecked(), Nan::Undefined());
2785+
Nan::Set(result, Nan::New<v8::String>("rows").ToLocalChecked(),
2786+
Nan::Undefined());
27852787

2786-
Nan::Set(result, Nan::New<v8::String>("resultSet").ToLocalChecked(), resultSet);
2788+
Nan::Set(result, Nan::New<v8::String>("resultSet").ToLocalChecked(),
2789+
resultSet);
27872790
}
27882791
else
27892792
{
27902793
rowArray = Connection::GetRows(executeBaton);
27912794
if(!(executeBaton->error).empty())
27922795
{
2793-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((executeBaton->error).c_str()).ToLocalChecked());
2796+
argv[0] = v8::Exception::Error(
2797+
Nan::New<v8::String>(executeBaton->error).ToLocalChecked());
27942798
argv[1] = Nan::Undefined();
27952799
goto exitAsyncAfterExecute;
27962800
}
@@ -2814,7 +2818,7 @@ void Connection::Async_AfterExecute(uv_work_t *req)
28142818
{
28152819
argv[0] = v8::Exception::Error (
28162820
Nan::New<v8::String> (
2817-
(executeBaton->error).c_str()).ToLocalChecked ());
2821+
executeBaton->error).ToLocalChecked ());
28182822
argv[1] = Nan::Undefined ();
28192823
goto exitAsyncAfterExecute;
28202824
}
@@ -2823,24 +2827,34 @@ void Connection::Async_AfterExecute(uv_work_t *req)
28232827
Nan::New<v8::String>("outBinds").ToLocalChecked(),
28242828
outBindValue,
28252829
v8::ReadOnly);
2826-
Nan::Set(result, Nan::New<v8::String>("rowsAffected").ToLocalChecked(), Nan::Undefined());
2830+
Nan::Set(result, Nan::New<v8::String>("rowsAffected").ToLocalChecked(),
2831+
Nan::Undefined());
28272832

2828-
Nan::Set(result, Nan::New<v8::String>("rows").ToLocalChecked(), Nan::Undefined());
2829-
Nan::Set(result, Nan::New<v8::String>("metaData").ToLocalChecked(), Nan::Undefined());
2833+
Nan::Set(result, Nan::New<v8::String>("rows").ToLocalChecked(),
2834+
Nan::Undefined());
2835+
Nan::Set(result, Nan::New<v8::String>("metaData").ToLocalChecked(),
2836+
Nan::Undefined());
28302837
break;
28312838
default :
2832-
Nan::ForceSet(result, Nan::New<v8::String>("rowsAffected").ToLocalChecked(),
2833-
Nan::New<v8::Integer>((unsigned int) executeBaton->rowsAffected), v8::ReadOnly);
2839+
Nan::ForceSet(result,
2840+
Nan::New<v8::String>("rowsAffected").ToLocalChecked(),
2841+
Nan::New<v8::Integer>((unsigned int) executeBaton->rowsAffected),
2842+
v8::ReadOnly);
28342843
if( executeBaton->numOutBinds )
28352844
{
2836-
Nan::ForceSet(result, Nan::New<v8::String>("outBinds").ToLocalChecked(), Connection::GetOutBinds(executeBaton), v8::ReadOnly);
2845+
Nan::ForceSet(result,
2846+
Nan::New<v8::String>("outBinds").ToLocalChecked(),
2847+
Connection::GetOutBinds(executeBaton), v8::ReadOnly);
28372848
}
28382849
else
28392850
{
2840-
Nan::Set(result, Nan::New<v8::String>("outBinds").ToLocalChecked(),Nan::Undefined());
2851+
Nan::Set(result, Nan::New<v8::String>("outBinds").ToLocalChecked(),
2852+
Nan::Undefined());
28412853
}
2842-
Nan::Set(result, Nan::New<v8::String>("rows").ToLocalChecked(), Nan::Undefined());
2843-
Nan::Set(result, Nan::New<v8::String>("metaData").ToLocalChecked(), Nan::Undefined());
2854+
Nan::Set(result, Nan::New<v8::String>("rows").ToLocalChecked(),
2855+
Nan::Undefined());
2856+
Nan::Set(result, Nan::New<v8::String>("metaData").ToLocalChecked(),
2857+
Nan::Undefined());
28442858
break;
28452859
}
28462860
argv[1] = result;
@@ -2978,8 +2992,7 @@ v8::Local<v8::Value> Connection::GetRows (eBaton* executeBaton)
29782992
if ( executeBaton->error.empty () )
29792993
{
29802994
Nan::Set(row,
2981-
Nan::New<v8::String>(executeBaton->mInfo[j].name.c_str(),
2982-
(int) executeBaton->mInfo[j].name.length()).ToLocalChecked(),
2995+
Nan::New<v8::String>(executeBaton->mInfo[j].name).ToLocalChecked(),
29832996
val );
29842997
}
29852998
else
@@ -3432,8 +3445,7 @@ v8::Local<v8::Value> Connection::GetOutBindObject ( eBaton *executeBaton )
34323445
if ( executeBaton->error.empty () )
34333446
{
34343447
Nan::Set( objectBinds,
3435-
Nan::New<v8::String>( binds[index]->key.c_str(),
3436-
(int) binds[index]->key.length() ).ToLocalChecked(),
3448+
Nan::New<v8::String>( binds[index]->key ).ToLocalChecked(),
34373449
val );
34383450
}
34393451
else
@@ -3594,7 +3606,8 @@ void Connection::Async_AfterRelease(uv_work_t *req)
35943606
Local<Value> argv[1];
35953607

35963608
if(!(releaseBaton->error).empty())
3597-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((releaseBaton->error).c_str()).ToLocalChecked());
3609+
argv[0] = v8::Exception::Error(
3610+
Nan::New<v8::String>(releaseBaton->error).ToLocalChecked());
35983611
else
35993612
argv[0] = Nan::Undefined();
36003613

@@ -3708,7 +3721,8 @@ void Connection::Async_AfterCommit (uv_work_t *req)
37083721
Local<Value> argv[1];
37093722

37103723
if(!(commitBaton->error).empty())
3711-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((commitBaton->error).c_str()).ToLocalChecked());
3724+
argv[0] = v8::Exception::Error(
3725+
Nan::New<v8::String>(commitBaton->error).ToLocalChecked());
37123726
else
37133727
argv[0] = Nan::Undefined();
37143728

@@ -3813,7 +3827,8 @@ void Connection::Async_AfterRollback(uv_work_t *req)
38133827
Local<Value> argv[1];
38143828

38153829
if(!(rollbackBaton->error).empty())
3816-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((rollbackBaton->error).c_str()).ToLocalChecked());
3830+
argv[0] = v8::Exception::Error(
3831+
Nan::New<v8::String>(rollbackBaton->error).ToLocalChecked());
38173832
else
38183833
argv[0] = Nan::Undefined();
38193834

@@ -3922,7 +3937,8 @@ void Connection::Async_AfterBreak (uv_work_t *req)
39223937
Local<Value> argv[1];
39233938

39243939
if(!(breakBaton->error).empty())
3925-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((breakBaton->error).c_str()).ToLocalChecked());
3940+
argv[0] = v8::Exception::Error(
3941+
Nan::New<v8::String>(breakBaton->error).ToLocalChecked());
39263942
else
39273943
argv[0] = Nan::Undefined();
39283944
Local<Function> callback = Nan::New<Function>(breakBaton->cb);
@@ -4441,8 +4457,10 @@ v8::Local<v8::Value> Connection::NewLob(eBaton* executeBaton,
44414457
argv[0] = iLob;
44424458

44434459
Local<Value> result =
4444-
Local<Function>::Cast(jsOracledb->Get(Nan::New<v8::String>("newLob").ToLocalChecked()))->Call(
4445-
jsOracledb, 1, argv);
4460+
Local<Function>::Cast(
4461+
jsOracledb->Get(
4462+
Nan::New<v8::String>("newLob").ToLocalChecked()))->Call(
4463+
jsOracledb, 1, argv);
44464464

44474465
return scope.Escape(result);
44484466
}

src/njs/src/njsIntLob.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,8 @@ void ILob::Async_AfterRead(uv_work_t *req)
975975

976976
if(!(lobBaton->error).empty())
977977
{
978-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((lobBaton->error).c_str()).ToLocalChecked());
978+
argv[0] = v8::Exception::Error(
979+
Nan::New<v8::String>(lobBaton->error).ToLocalChecked());
979980
argv[1] = Nan::Undefined();
980981
}
981982
else
@@ -987,7 +988,7 @@ void ILob::Async_AfterRead(uv_work_t *req)
987988
if (iLob->fetchType_ == DpiClob)
988989
{
989990
Local<Value> str = Nan::New<v8::String>((char *)iLob->buf_,
990-
iLob->amountRead_).ToLocalChecked();
991+
iLob->amountRead_).ToLocalChecked();
991992
argv[1] = str;
992993
}
993994
else
@@ -1171,7 +1172,8 @@ void ILob::Async_AfterWrite(uv_work_t *req)
11711172
iLob->state_ = NJS_INACTIVE; // mark Lob as inactive as back in main thread
11721173

11731174
if(!(lobBaton->error).empty())
1174-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((lobBaton->error).c_str()).ToLocalChecked());
1175+
argv[0] = v8::Exception::Error(
1176+
Nan::New<v8::String>(lobBaton->error).ToLocalChecked());
11751177
else
11761178
argv[0] = Nan::Undefined();
11771179

src/njs/src/njsOracle.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ NAN_GETTER(Oracledb::GetConnectionClass)
542542
{
543543
Oracledb *oracledb = Nan::ObjectWrap::Unwrap<Oracledb>(info.Holder());
544544
NJS_CHECK_OBJECT_VALID2(oracledb, info);
545-
Local<String> value = Nan::New<v8::String>(oracledb->connClass_.c_str(),
546-
(int)oracledb->connClass_.length ()).ToLocalChecked();
545+
Local<String> value = Nan::New<v8::String>
546+
(oracledb->connClass_).ToLocalChecked();
547547
info.GetReturnValue().Set(value);
548548
}
549549

@@ -857,7 +857,8 @@ void Oracledb::Async_AfterGetConnection (uv_work_t *req)
857857
Local<Value> argv[2];
858858
if( !(connBaton->error).empty() )
859859
{
860-
argv[0] = v8::Exception::Error(Nan::New<v8::String>( (connBaton->error).c_str() ).ToLocalChecked());
860+
argv[0] = v8::Exception::Error(Nan::New<v8::String>(
861+
connBaton->error ).ToLocalChecked());
861862
argv[1] = Nan::Null();
862863
}
863864
else
@@ -1017,7 +1018,8 @@ void Oracledb::Async_AfterCreatePool (uv_work_t *req)
10171018

10181019
if (!poolBaton->error.empty())
10191020
{
1020-
argv[0] = v8::Exception::Error(Nan::New<v8::String>(( poolBaton->error).c_str() ).ToLocalChecked());
1021+
argv[0] = v8::Exception::Error(
1022+
Nan::New<v8::String>( poolBaton->error ).ToLocalChecked());
10211023
argv[1] = Nan::Undefined();
10221024
}
10231025
else

src/njs/src/njsPool.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ void Pool::Init(Handle<Object> target)
136136
Pool::SetStmtCacheSize );
137137

138138
poolTemplate_s.Reset( temp );
139-
Nan::Set(target, Nan::New<v8::String>("Pool").ToLocalChecked(), temp->GetFunction());
139+
Nan::Set(target, Nan::New<v8::String>("Pool").ToLocalChecked(),
140+
temp->GetFunction());
140141
}
141142

142143
/*****************************************************************************/
@@ -483,7 +484,8 @@ void Pool::Async_AfterGetConnection(uv_work_t *req)
483484

484485
if(!(connBaton->error).empty())
485486
{
486-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((connBaton->error).c_str()).ToLocalChecked());
487+
argv[0] = v8::Exception::Error(
488+
Nan::New<v8::String>(connBaton->error).ToLocalChecked());
487489
argv[1] = Nan::Undefined();
488490
}
489491
else
@@ -602,7 +604,8 @@ void Pool::Async_AfterTerminate(uv_work_t *req)
602604

603605
if(!(terminateBaton->error).empty())
604606
{
605-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((terminateBaton->error).c_str()).ToLocalChecked());
607+
argv[0] = v8::Exception::Error(
608+
Nan::New<v8::String>(terminateBaton->error).ToLocalChecked());
606609
}
607610
else
608611
{

src/njs/src/njsResultSet.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ void ResultSet::Init(Handle<Object> target)
143143
ResultSet::SetMetaData );
144144

145145
resultSetTemplate_s.Reset( temp);
146-
Nan::Set(target, Nan::New<v8::String>("ResultSet").ToLocalChecked(), temp->GetFunction());
146+
Nan::Set(target, Nan::New<v8::String>("ResultSet").ToLocalChecked(),
147+
temp->GetFunction());
147148
}
148149

149150
/*****************************************************************************/
@@ -480,7 +481,8 @@ void ResultSet::Async_AfterGetRows(uv_work_t *req)
480481

481482
if(!(getRowsBaton->error).empty())
482483
{
483-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((getRowsBaton->error).c_str()).ToLocalChecked());
484+
argv[0] = v8::Exception::Error(
485+
Nan::New<v8::String>(getRowsBaton->error).ToLocalChecked());
484486
argv[1] = Nan::Undefined();
485487
}
486488
else
@@ -497,7 +499,8 @@ void ResultSet::Async_AfterGetRows(uv_work_t *req)
497499
rowsArray = Connection::GetRows(ebaton);
498500
if(!(ebaton->error).empty())
499501
{
500-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((ebaton->error).c_str()).ToLocalChecked());
502+
argv[0] = v8::Exception::Error(
503+
Nan::New<v8::String>(ebaton->error).ToLocalChecked());
501504
argv[1] = Nan::Undefined();
502505
goto exitAsyncAfterGetRows;
503506
}
@@ -653,7 +656,8 @@ void ResultSet::Async_AfterClose(uv_work_t *req)
653656

654657
if(!(closeBaton->error).empty())
655658
{
656-
argv[0] = v8::Exception::Error(Nan::New<v8::String>((closeBaton->error).c_str()).ToLocalChecked());
659+
argv[0] = v8::Exception::Error(
660+
Nan::New<v8::String>(closeBaton->error).ToLocalChecked());
657661
if(!closeBaton->errOnActiveOrInvalid)
658662
{
659663
closeBaton->njsRS->state_ = NJS_INACTIVE;

0 commit comments

Comments
 (0)