Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83a2d7c

Browse files
committed
Index text snippets in regular expressions to avoid trying to match all of them
Also switch to re2 instead of boost::regex, for better performance. All in all, this amounts to the user agent parsing taking about a tenth of the time.
1 parent 7af11a5 commit 83a2d7c

16 files changed

+1175
-155
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: cpp
22
before_install:
33
- sudo apt-get update -qq
4-
- sudo apt-get install -qq libboost-regex-dev libyaml-cpp-dev cmake libgtest-dev
4+
- sudo apt-get install -qq libboost-regex-dev libyaml-cpp-dev cmake libgtest-dev libre2-dev
55
- cd /usr/src/gtest
66
- sudo cmake CMakeLists.txt
77
- sudo make

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1-
LDFLAGS += -lboost_regex -lyaml-cpp
2-
CXXFLAGS += -std=c++0x -Wall -Werror -g -fPIC -O3
1+
ifndef KEEP_ENV_VARS
2+
LDFLAGS += -lre2 -lyaml-cpp
3+
CXXFLAGS += -std=c++14 -Wall -Werror -g -fPIC -O3
4+
endif
35

46
# wildcard object build target
57
%.o: %.cpp
6-
$(CXX) -c $(CXXFLAGS) $*.cpp -o $*.o
7-
@$(CXX) -MM $(CXXFLAGS) $*.cpp > $*.d
8+
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $*.cpp -o $*.o
9+
@$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $*.cpp > $*.d
810

911
uaparser_cpp: libuaparser_cpp.a
1012

11-
libuaparser_cpp.a: UaParser.o
13+
OBJECT_FILES = UaParser.o \
14+
internal/Pattern.o \
15+
internal/AlternativeExpander.o \
16+
internal/SnippetIndex.o \
17+
internal/ReplaceTemplate.o
18+
19+
libuaparser_cpp.a: $(OBJECT_FILES)
1220
ar rcs $@ $^
1321

14-
libuaparser_cpp.so: UaParser.o
22+
libuaparser_cpp.so: $(OBJECT_FILES)
1523
$(CXX) $< -shared $(LDFLAGS) -o $@
1624

1725
UaParserTest: libuaparser_cpp.a UaParserTest.o
1826
$(CXX) $^ -o $@ libuaparser_cpp.a $(LDFLAGS) -lgtest -lpthread
1927

20-
test: UaParserTest libuaparser_cpp.so
28+
test: UaParserTest libuaparser_cpp.a
2129
./UaParserTest
2230

2331
# clean everything generated

0 commit comments

Comments
 (0)