File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -368,22 +368,20 @@ Color Color::html(const String &p_rgba) {
368368bool Color::html_is_valid (const String &p_color) {
369369 String color = p_color;
370370
371- if (color.length () == 0 ) {
371+ if (color.is_empty () ) {
372372 return false ;
373373 }
374- if (color[0 ] == ' #' ) {
375- color = color.substr (1 );
376- }
377374
378- // Check if the amount of hex digits is valid.
375+ int current_pos = (color[ 0 ] == ' # ' ) ? 1 : 0 ;
379376 int len = color.length ();
380- if (!(len == 3 || len == 4 || len == 6 || len == 8 )) {
377+ int num_of_digits = len - current_pos;
378+ if (!(num_of_digits == 3 || num_of_digits == 4 || num_of_digits == 6 || num_of_digits == 8 )) {
381379 return false ;
382380 }
383381
384382 // Check if each hex digit is valid.
385- for (int i = 0 ; i < len; i++) {
386- if (_parse_col4 (color, i) == - 1 ) {
383+ for (int i = current_pos ; i < len; i++) {
384+ if (! is_hex_digit (p_color[i]) ) {
387385 return false ;
388386 }
389387 }
You can’t perform that action at this time.
0 commit comments