I am working on a Roman numerals calculator. For an input validity test I'm using this function: 

```
bool isValidRomanNumeral(string& roman){
    // no test for one-digit Roman numeral  
    if (roman.size() == 1) return true;
    for(size_t i=0; i<roman.size()-1; i++){
        // each more significant digit is either >= previous digit (II, VI, etc)
        if(toArab(to_string(roman[i])) >= toArab(to_string(roman[i+1])) ||
           // or 5 times smaller than previous digit (IV, XL, CD, etc)
           5*toArab(to_string(roman[i])) == toArab(to_string(roman[i+1])) ||
           // or 10 times smaller than previous digit (IX, XC, CM, etc)
           10*toArab(to_string(roman[i])) == toArab(to_string(roman[i+1])));
        else return false;
    }
    return true;}

```

Function: `int toArab(string roman)`

```
int toArab(string s){ 
 map<char, int> roman;
 roman['M'] = 1000;
 roman['D'] = 500;
 roman['C'] = 100;
 roman['L'] = 50;
 roman['X'] = 10;
 roman['V'] = 5;
 roman['I'] = 1;
 int res = 0;
 for(int i=0; i<s.size()-1; ++i){
    if(roman[s[i]] < roman[s[i+1]]) res -= roman[s[i]];
    else res += roman[s[i]];
 }
 res += roman[s[s.size()-1]];
 return res;}

```

Is there something else that can be done for optimization? Is there a better way to check for Roman numeral validity?