Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- (unknown)
Instance Method Summary collapse
Instance Method Details
#ascii_blank? ⇒ Boolean
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'ext/sin_fast_blank/sin_fast_blank.c', line 298 static VALUE rb_str_ascii_blank(VALUE str) { long len = RSTRING_LEN(str); if (len == 0) return Qtrue; const unsigned char* ptr = (const unsigned char*)RSTRING_PTR(str); const unsigned char* end = ptr + len; rb_encoding* enc = STR_ENC_GET(str); if (rb_enc_asciicompat(enc)) { const unsigned char* non_ascii_pos = NULL; bool is_blank = false; #ifdef __AVX2__ is_blank = check_ascii_blank_avx2(ptr, (size_t)len, &non_ascii_pos); #elif defined(__SSE2__) is_blank = check_ascii_blank_sse2(ptr, (size_t)len, &non_ascii_pos); #elif defined(__ARM_NEON) && defined(__aarch64__) is_blank = check_ascii_blank_neon(ptr, (size_t)len, &non_ascii_pos); #else is_blank = check_ascii_blank_scalar(ptr, (size_t)len, &non_ascii_pos); #endif if (is_blank) return Qtrue; if (non_ascii_pos == NULL) return Qfalse; ptr = non_ascii_pos; } while (ptr < end) { int clen; unsigned int codepoint = rb_enc_codepoint_len((const char*)ptr, (const char*)end, &clen, enc); if (codepoint != 0 && !rb_isspace(codepoint)) return Qfalse; ptr += clen; } return Qtrue; } |
#blank? ⇒ Boolean
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'ext/sin_fast_blank/sin_fast_blank.c', line 260 static VALUE rb_str_blank(VALUE str) { long len = RSTRING_LEN(str); if (len == 0) return Qtrue; const unsigned char* ptr = (const unsigned char*)RSTRING_PTR(str); const unsigned char* end = ptr + len; rb_encoding* enc = STR_ENC_GET(str); if (rb_enc_asciicompat(enc)) { const unsigned char* non_ascii_pos = NULL; bool is_blank = false; #ifdef __AVX2__ is_blank = check_blank_avx2(ptr, (size_t)len, &non_ascii_pos); #elif defined(__SSE2__) is_blank = check_blank_sse2(ptr, (size_t)len, &non_ascii_pos); #elif defined(__ARM_NEON) && defined(__aarch64__) is_blank = check_blank_neon(ptr, (size_t)len, &non_ascii_pos); #else is_blank = check_blank_scalar(ptr, (size_t)len, &non_ascii_pos); #endif if (is_blank) return Qtrue; if (non_ascii_pos == NULL) return Qfalse; ptr = non_ascii_pos; } while (ptr < end) { int clen; unsigned int codepoint = rb_enc_codepoint_len((const char*)ptr, (const char*)end, &clen, enc); if (!is_unicode_blank(codepoint)) return Qfalse; ptr += clen; } return Qtrue; } |