From 6c66df95c81c6f0780cdfbcf9ba30a58d62496eb Mon Sep 17 00:00:00 2001 From: Vesa Karvonen Date: Wed, 23 Jan 2002 15:16:21 +0000 Subject: [PATCH] Minor optimization of list processing [SVN r12458] --- include/boost/preprocessor/list/append.hpp | 2 +- include/boost/preprocessor/list/filter.hpp | 2 +- include/boost/preprocessor/list/first_n.hpp | 4 ++-- include/boost/preprocessor/list/reverse.hpp | 4 ++-- include/boost/preprocessor/list/transform.hpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/boost/preprocessor/list/append.hpp b/include/boost/preprocessor/list/append.hpp index d9ab752..2adec58 100644 --- a/include/boost/preprocessor/list/append.hpp +++ b/include/boost/preprocessor/list/append.hpp @@ -36,6 +36,6 @@ produces a list containing 1, 2, 3 and 4. #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_LIST_APPEND_D(D,L,P) BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_APPEND_F,L,P) -#define BOOST_PP_LIST_APPEND_F(D,H,P) BOOST_PP_LIST_CONS(H,P) +#define BOOST_PP_LIST_APPEND_F(D,H,P) (H,P,1) #endif #endif diff --git a/include/boost/preprocessor/list/filter.hpp b/include/boost/preprocessor/list/filter.hpp index 1f3e3c9..bf24432 100644 --- a/include/boost/preprocessor/list/filter.hpp +++ b/include/boost/preprocessor/list/filter.hpp @@ -32,7 +32,7 @@ expands to a list containing 1 and 3. #define BOOST_PP_LIST_FILTER(F,P,L) BOOST_PP_LIST_FILTER_D(0,F,P,L) #ifndef DOXYGEN_SHOULD_SKIP_THIS -#define BOOST_PP_LIST_FILTER_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_FILTER_F,L,(F,P,BOOST_PP_LIST_NIL))) +#define BOOST_PP_LIST_FILTER_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_FILTER_F,L,(F,P,(_,_,0)))) #define BOOST_PP_LIST_FILTER_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P),BOOST_PP_IF(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE_ELEM(3,1,P),H),BOOST_PP_LIST_CONS,BOOST_PP_TUPLE2_ELEM1)(H,BOOST_PP_TUPLE_ELEM(3,2,P))) #endif #endif diff --git a/include/boost/preprocessor/list/first_n.hpp b/include/boost/preprocessor/list/first_n.hpp index 2af3827..7e09f6b 100644 --- a/include/boost/preprocessor/list/first_n.hpp +++ b/include/boost/preprocessor/list/first_n.hpp @@ -34,8 +34,8 @@ expands to a list containing + and -. #define BOOST_PP_LIST_FIRST_N(N,L) BOOST_PP_LIST_FIRST_N_D(0,N,L) #ifndef DOXYGEN_SHOULD_SKIP_THIS -#define BOOST_PP_LIST_FIRST_N_D(D,N,L) BOOST_PP_LIST_REVERSE_D(D,BOOST_PP_TUPLE_ELEM(3,0,BOOST_PP_WHILE##D(BOOST_PP_LIST_FIRST_N_C,BOOST_PP_LIST_FIRST_N_F,(BOOST_PP_LIST_NIL,L,N)))) +#define BOOST_PP_LIST_FIRST_N_D(D,N,L) BOOST_PP_LIST_REVERSE_D(D,BOOST_PP_TUPLE_ELEM(3,0,BOOST_PP_WHILE##D(BOOST_PP_LIST_FIRST_N_C,BOOST_PP_LIST_FIRST_N_F,((_,_,0),L,N)))) #define BOOST_PP_LIST_FIRST_N_C(D,X) BOOST_PP_TUPLE_ELEM(3,2,X) -#define BOOST_PP_LIST_FIRST_N_F(D,X) (BOOST_PP_LIST_CONS(BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_ELEM(3,1,X)),BOOST_PP_TUPLE_ELEM(3,0,X)),BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(3,1,X)),BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(3,2,X))) +#define BOOST_PP_LIST_FIRST_N_F(D,X) ((BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_ELEM(3,1,X)),BOOST_PP_TUPLE_ELEM(3,0,X),1),BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(3,1,X)),BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(3,2,X))) #endif #endif diff --git a/include/boost/preprocessor/list/reverse.hpp b/include/boost/preprocessor/list/reverse.hpp index 6e2960f..05b1a14 100644 --- a/include/boost/preprocessor/list/reverse.hpp +++ b/include/boost/preprocessor/list/reverse.hpp @@ -32,7 +32,7 @@ expands to a list containing C, B and A. #define BOOST_PP_LIST_REVERSE(L) BOOST_PP_LIST_REVERSE_D(0,L) #ifndef DOXYGEN_SHOULD_SKIP_THIS -#define BOOST_PP_LIST_REVERSE_D(D,L) BOOST_PP_LIST_FOLD_LEFT_D(D,BOOST_PP_LIST_REVERSE_F,BOOST_PP_LIST_NIL,L) -#define BOOST_PP_LIST_REVERSE_F(D,P,H) BOOST_PP_LIST_CONS(H,P) +#define BOOST_PP_LIST_REVERSE_D(D,L) BOOST_PP_LIST_FOLD_LEFT_D(D,BOOST_PP_LIST_REVERSE_F,(_,_,0),L) +#define BOOST_PP_LIST_REVERSE_F(D,P,H) (H,P,1) #endif #endif diff --git a/include/boost/preprocessor/list/transform.hpp b/include/boost/preprocessor/list/transform.hpp index aa0ff52..bd8e917 100644 --- a/include/boost/preprocessor/list/transform.hpp +++ b/include/boost/preprocessor/list/transform.hpp @@ -42,7 +42,7 @@ expands to a list containing 3 and 4. #define BOOST_PP_LIST_TRANSFORM(F,P,L) BOOST_PP_LIST_TRANSFORM_D(0,F,P,L) #ifndef DOXYGEN_SHOULD_SKIP_THIS -#define BOOST_PP_LIST_TRANSFORM_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_TRANSFORM_F,L,(F,P,BOOST_PP_LIST_NIL))) -#define BOOST_PP_LIST_TRANSFORM_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P),BOOST_PP_LIST_CONS(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE_ELEM(3,1,P),H),BOOST_PP_TUPLE_ELEM(3,2,P))) +#define BOOST_PP_LIST_TRANSFORM_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_TRANSFORM_F,L,(F,P,(_,_,0)))) +#define BOOST_PP_LIST_TRANSFORM_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P),(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE_ELEM(3,1,P),H),BOOST_PP_TUPLE_ELEM(3,2,P),1)) #endif #endif