Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make(1): inline Vector_Get



details:   https://anonhg.NetBSD.org/src/rev/fc3f25b8e593
branches:  trunk
changeset: 956372:fc3f25b8e593
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Oct 28 02:43:16 2020 +0000

description:
make(1): inline Vector_Get

It is simple enough that it neither bloats the code nor warrants the
extra function call.

diffstat:

 usr.bin/make/lst.c |  13 ++-----------
 usr.bin/make/lst.h |  13 +++++++++++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diffs (61 lines):

diff -r e8f580f95882 -r fc3f25b8e593 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Wed Oct 28 01:58:37 2020 +0000
+++ b/usr.bin/make/lst.c        Wed Oct 28 02:43:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.90 2020/10/25 13:06:12 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.91 2020/10/28 02:43:16 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.90 2020/10/25 13:06:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.91 2020/10/28 02:43:16 rillig Exp $");
 
 static ListNode *
 LstNodeNew(ListNode *prev, ListNode *next, void *datum)
@@ -283,15 +283,6 @@
     v->items = bmake_malloc(v->priv_cap * v->itemSize);
 }
 
-/* Return the pointer to the given item in the vector.
- * The returned data is valid until the next modifying operation. */
-void *
-Vector_Get(Vector *v, size_t i)
-{
-    unsigned char *items = v->items;
-    return items + i * v->itemSize;
-}
-
 /* Add space for a new item to the vector and return a pointer to that space.
  * The returned data is valid until the next modifying operation. */
 void *
diff -r e8f580f95882 -r fc3f25b8e593 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Wed Oct 28 01:58:37 2020 +0000
+++ b/usr.bin/make/lst.h        Wed Oct 28 02:43:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lst.h,v 1.83 2020/10/25 13:31:16 rillig Exp $  */
+/*     $NetBSD: lst.h,v 1.84 2020/10/28 02:43:16 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -170,7 +170,16 @@
 } Vector;
 
 void Vector_Init(Vector *, size_t);
-void *Vector_Get(Vector *, size_t);
+
+/* Return the pointer to the given item in the vector.
+ * The returned data is valid until the next modifying operation. */
+static inline MAKE_ATTR_UNUSED void *
+Vector_Get(Vector *v, size_t i)
+{
+    unsigned char *items = v->items;
+    return items + i * v->itemSize;
+}
+
 void *Vector_Push(Vector *);
 void *Vector_Pop(Vector *);
 void Vector_Done(Vector *);



Home | Main Index | Thread Index | Old Index