[PATCH 2/5] core: Cache info about flexible arrays in class__has_flexible_array()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Just saving some calculations, to be in line with class->holes_searched,
etc.

Cc: "Gustavo A. R. Silva" <gustavoars@xxxxxxxxxx>
Cc: Willy Tarreau <w@xxxxxx>
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
 dwarves.c | 12 +++++++++++-
 dwarves.h |  2 ++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/dwarves.c b/dwarves.c
index 3d91e629277a329f..f5bc9cb27adee649 100644
--- a/dwarves.c
+++ b/dwarves.c
@@ -1575,7 +1575,7 @@ void lexblock__add_label(struct lexblock *block, struct label *label)
 	lexblock__add_tag(block, &label->ip.tag);
 }
 
-bool class__has_flexible_array(struct class *class, const struct cu *cu)
+static bool __class__has_flexible_array(struct class *class, const struct cu *cu)
 {
 	struct class_member *member = type__last_member(&class->type);
 
@@ -1598,6 +1598,16 @@ bool class__has_flexible_array(struct class *class, const struct cu *cu)
 	return false;
 }
 
+bool class__has_flexible_array(struct class *class, const struct cu *cu)
+{
+	if (!class->flexible_array_verified) {
+		class->has_flexible_array = __class__has_flexible_array(class, cu);
+		class->flexible_array_verified = true;
+	}
+
+	return class->has_flexible_array;
+}
+
 const struct class_member *class__find_bit_hole(const struct class *class,
 					    const struct class_member *trailer,
 						const uint16_t bit_hole_size)
diff --git a/dwarves.h b/dwarves.h
index 757fc05dd3363bf1..bcf701706c61b4f5 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -1412,6 +1412,8 @@ struct class {
 	uint8_t		 pre_bit_hole;
 	uint8_t		 bit_padding;
 	bool		 holes_searched;
+	bool		 flexible_array_verified;
+	bool		 has_flexible_array;
 	bool		 is_packed;
 	void		 *priv;
 };
-- 
2.46.2





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux