Skip to content
File

Blob: patches/v8/0029-Add-v8-String-IsFlat-API.patch

1.2 KB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: James M Snell <jsnell@cloudflare.com>
3Date: Thu, 6 Nov 2025 10:58:38 -0800
4Subject: Add v8::String::IsFlat API
5 
6Tells us if a string is already flattened or not.
7 
8Signed-off-by: James M Snell <jsnell@cloudflare.com>
9 
10diff --git a/include/v8-primitive.h b/include/v8-primitive.h
11index 2b443d97d34fc6e69c47b9fd842898b9a2e43449..068adcc87d02e7c3333c3c6633b51be75f322e42 100644
12--- a/include/v8-primitive.h
13+++ b/include/v8-primitive.h
14@@ -157,6 +157,11 @@ class V8_EXPORT String : public Name {
15 */
16 bool ContainsOnlyOneByte() const;
17
18+ /**
19+ * Returns true if this string is flat
20+ */
21+ bool IsFlat() const;
22+
23 struct WriteFlags {
24 enum {
25 kNone = 0,
26diff --git a/src/api/api.cc b/src/api/api.cc
27index 8afb25744487519738fd58f49f197537ef070b4a..c1b6bb583314a90dfe77e2f2184db9f4cf722d77 100644
28--- a/src/api/api.cc
29+++ b/src/api/api.cc
30@@ -5819,6 +5819,10 @@ bool String::IsOneByte() const {
31 return Utils::OpenDirectHandle(this)->IsOneByteRepresentation();
32 }
33
34+bool String::IsFlat() const {
35+ return Utils::OpenDirectHandle(this)->IsFlat();
36+}
37+
38 class ContainsOnlyOneByteHelper {
39 public:
40 ContainsOnlyOneByteHelper() : is_one_byte_(true) {}