mirror of https://gitee.com/bigwinds/arangodb
turned assertions into ifs
This commit is contained in:
parent
0975fb8349
commit
0cb5b70a3e
|
@ -499,7 +499,9 @@ static v8::Handle<v8::Value> EnsureIndexLocal (TRI_vocbase_col_t const* collecti
|
|||
|
||||
// extract type
|
||||
TRI_json_t* value = TRI_LookupArrayJson(json, "type");
|
||||
TRI_ASSERT(TRI_IsStringJson(value));
|
||||
if (! TRI_IsStringJson(value)) {
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
TRI_idx_type_e type = TRI_TypeIndex(value->_value._string.data);
|
||||
|
||||
|
@ -532,8 +534,14 @@ static v8::Handle<v8::Value> EnsureIndexLocal (TRI_vocbase_col_t const* collecti
|
|||
for (size_t i = 0; i < value->_value._objects._length; ++i) {
|
||||
TRI_json_t const* v = static_cast<TRI_json_t const*>(TRI_AtVector(&value->_value._objects, i));
|
||||
|
||||
TRI_ASSERT(TRI_IsStringJson(v));
|
||||
TRI_PushBackVectorPointer(&attributes, v->_value._string.data);
|
||||
if (TRI_IsStringJson(v)) {
|
||||
TRI_PushBackVectorPointer(&attributes, v->_value._string.data);
|
||||
}
|
||||
}
|
||||
|
||||
// check if copying was successful
|
||||
if (value->_value._objects._length != TRI_LengthVectorPointer(&attributes)) {
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -572,6 +580,10 @@ static v8::Handle<v8::Value> EnsureIndexLocal (TRI_vocbase_col_t const* collecti
|
|||
}
|
||||
|
||||
case TRI_IDX_TYPE_GEO1_INDEX: {
|
||||
if (attributes._length != 1) {
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
TRI_ASSERT(attributes._length == 1);
|
||||
|
||||
bool ignoreNull = false;
|
||||
|
@ -606,6 +618,10 @@ static v8::Handle<v8::Value> EnsureIndexLocal (TRI_vocbase_col_t const* collecti
|
|||
}
|
||||
|
||||
case TRI_IDX_TYPE_GEO2_INDEX: {
|
||||
if (attributes._length != 2) {
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
TRI_ASSERT(attributes._length == 2);
|
||||
|
||||
bool ignoreNull = false;
|
||||
|
@ -634,6 +650,10 @@ static v8::Handle<v8::Value> EnsureIndexLocal (TRI_vocbase_col_t const* collecti
|
|||
}
|
||||
|
||||
case TRI_IDX_TYPE_HASH_INDEX: {
|
||||
if (attributes._length == 0) {
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
TRI_ASSERT(attributes._length > 0);
|
||||
|
||||
if (create) {
|
||||
|
@ -653,6 +673,10 @@ static v8::Handle<v8::Value> EnsureIndexLocal (TRI_vocbase_col_t const* collecti
|
|||
}
|
||||
|
||||
case TRI_IDX_TYPE_SKIPLIST_INDEX: {
|
||||
if (attributes._length == 0) {
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
TRI_ASSERT(attributes._length > 0);
|
||||
|
||||
if (create) {
|
||||
|
@ -671,6 +695,10 @@ static v8::Handle<v8::Value> EnsureIndexLocal (TRI_vocbase_col_t const* collecti
|
|||
}
|
||||
|
||||
case TRI_IDX_TYPE_FULLTEXT_INDEX: {
|
||||
if (attributes._length != 1) {
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
TRI_ASSERT(attributes._length == 1);
|
||||
|
||||
int minWordLength = TRI_FULLTEXT_MIN_WORD_LENGTH_DEFAULT;
|
||||
|
|
|
@ -585,6 +585,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper,
|
|||
shape->_sidEntry = s;
|
||||
shape->_sizeEntry = l;
|
||||
|
||||
// note: if 'found' is not a nullptr, the shaper will have freed variable 'shape'!
|
||||
found = shaper->findShape(shaper, &shape->base, create);
|
||||
|
||||
if (found == nullptr) {
|
||||
|
@ -652,6 +653,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper,
|
|||
shape->base._dataSize = TRI_SHAPE_SIZE_VARIABLE;
|
||||
shape->_sidEntry = s;
|
||||
|
||||
// note: if 'found' is not a nullptr, the shaper will have freed variable 'shape'!
|
||||
found = shaper->findShape(shaper, &shape->base, create);
|
||||
|
||||
if (found == nullptr) {
|
||||
|
@ -819,6 +821,7 @@ static bool FillShapeValueArray (TRI_shaper_t* shaper,
|
|||
for (i = 0; i < n; ++i, ++p) {
|
||||
TRI_json_t const* key = static_cast<TRI_json_t const*>(TRI_AtVector(&json->_value._objects, 2 * i));
|
||||
TRI_ASSERT(key != nullptr);
|
||||
TRI_ASSERT(key->_type == TRI_JSON_STRING);
|
||||
|
||||
char const* k = key->_value._string.data;
|
||||
|
||||
|
@ -959,7 +962,6 @@ static bool FillShapeValueArray (TRI_shaper_t* shaper,
|
|||
}
|
||||
}
|
||||
|
||||
TRI_Free(shaper->_memoryZone, dst->_value);
|
||||
TRI_Free(shaper->_memoryZone, values);
|
||||
TRI_Free(shaper->_memoryZone, a);
|
||||
|
||||
|
|
Loading…
Reference in New Issue