Module Name:    src
Committed By:   rillig
Date:           Wed Oct 28 02:43:16 UTC 2020

Modified Files:
        src/usr.bin/make: lst.c lst.h

Log Message:
make(1): inline Vector_Get

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


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/lst.c
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/make/lst.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.90 src/usr.bin/make/lst.c:1.91
--- src/usr.bin/make/lst.c:1.90	Sun Oct 25 13:06:12 2020
+++ src/usr.bin/make/lst.c	Wed Oct 28 02:43:16 2020
@@ -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 @@ Vector_Init(Vector *v, size_t itemSize)
     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 *

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.83 src/usr.bin/make/lst.h:1.84
--- src/usr.bin/make/lst.h:1.83	Sun Oct 25 13:31:16 2020
+++ src/usr.bin/make/lst.h	Wed Oct 28 02:43:16 2020
@@ -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 @@ typedef struct Vector {
 } 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 *);

Reply via email to