MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / operator==

Method operator==

src/server/angelscript/add_on/scriptarray/scriptarray.cpp:1052–1107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1050}
1051
1052bool CScriptArray::operator==(const CScriptArray &other) const
1053{
1054 if( objType != other.objType )
1055 return false;
1056
1057 if( GetSize() != other.GetSize() )
1058 return false;
1059
1060 asIScriptContext *cmpContext = 0;
1061 bool isNested = false;
1062
1063 if( subTypeId & ~asTYPEID_MASK_SEQNBR )
1064 {
1065 // Try to reuse the active context
1066 cmpContext = asGetActiveContext();
1067 if( cmpContext )
1068 {
1069 if( cmpContext->GetEngine() == objType->GetEngine() && cmpContext->PushState() >= 0 )
1070 isNested = true;
1071 else
1072 cmpContext = 0;
1073 }
1074 if( cmpContext == 0 )
1075 {
1076 // TODO: Ideally this context would be retrieved from a pool, so we don't have to
1077 // create a new one everytime. We could keep a context with the array object
1078 // but that would consume a lot of resources as each context is quite heavy.
1079 cmpContext = objType->GetEngine()->CreateContext();
1080 }
1081 }
1082
1083 // Check if all elements are equal
1084 bool isEqual = true;
1085 SArrayCache *cache = reinterpret_cast<SArrayCache*>(objType->GetUserData(ARRAY_CACHE));
1086 for( asUINT n = 0; n < GetSize(); n++ )
1087 if( !Equals(At(n), other.At(n), cmpContext, cache) )
1088 {
1089 isEqual = false;
1090 break;
1091 }
1092
1093 if( cmpContext )
1094 {
1095 if( isNested )
1096 {
1097 asEContextState state = cmpContext->GetState();
1098 cmpContext->PopState();
1099 if( state == asEXECUTION_ABORTED )
1100 cmpContext->Abort();
1101 }
1102 else
1103 cmpContext->Release();
1104 }
1105
1106 return isEqual;
1107}
1108
1109// internal

Callers 1

Calls 10

PushStateMethod · 0.80
CreateContextMethod · 0.80
GetStateMethod · 0.80
PopStateMethod · 0.80
AbortMethod · 0.80
GetSizeMethod · 0.45
GetEngineMethod · 0.45
GetUserDataMethod · 0.45
AtMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected