922 if (_name_len == 0) {
923 _name_len = strlen(_name);
924 }
925 return _name_len;
926 }
927
928 JVMFlag* JVMFlag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
929 float VMOptionsFuzzyMatchSimilarity = 0.7f;
930 JVMFlag* match = NULL;
931 float score;
932 float max_score = -1;
933
934 for (JVMFlag* current = &flagTable[0]; current->_name != NULL; current++) {
935 score = StringUtils::similarity(current->_name, strlen(current->_name), name, length);
936 if (score > max_score) {
937 max_score = score;
938 match = current;
939 }
940 }
941
942 if (!(match->is_unlocked() || match->is_unlocker())) {
943 if (!allow_locked) {
944 return NULL;
945 }
946 }
947
948 if (max_score < VMOptionsFuzzyMatchSimilarity) {
949 return NULL;
950 }
951
952 return match;
953 }
954
955 // Returns the address of the index'th element
956 static JVMFlag* address_of_flag(JVMFlagsWithType flag) {
957 assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
958 return &JVMFlag::flags[flag];
959 }
960
961 bool JVMFlagEx::is_default(JVMFlags flag) {
|
922 if (_name_len == 0) {
923 _name_len = strlen(_name);
924 }
925 return _name_len;
926 }
927
928 JVMFlag* JVMFlag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
929 float VMOptionsFuzzyMatchSimilarity = 0.7f;
930 JVMFlag* match = NULL;
931 float score;
932 float max_score = -1;
933
934 for (JVMFlag* current = &flagTable[0]; current->_name != NULL; current++) {
935 score = StringUtils::similarity(current->_name, strlen(current->_name), name, length);
936 if (score > max_score) {
937 max_score = score;
938 match = current;
939 }
940 }
941
942 if (match == NULL) {
943 return NULL;
944 }
945
946 if (!(match->is_unlocked() || match->is_unlocker())) {
947 if (!allow_locked) {
948 return NULL;
949 }
950 }
951
952 if (max_score < VMOptionsFuzzyMatchSimilarity) {
953 return NULL;
954 }
955
956 return match;
957 }
958
959 // Returns the address of the index'th element
960 static JVMFlag* address_of_flag(JVMFlagsWithType flag) {
961 assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
962 return &JVMFlag::flags[flag];
963 }
964
965 bool JVMFlagEx::is_default(JVMFlags flag) {
|