Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: Source/core/svg/SVGPathByteStreamSource.h

Issue 133163007: Use memcpy in SVGPathByteStreamSource::readType (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 virtual bool parseArcToSegment(float&, float&, float&, bool&, bool&, FloatPo int&) OVERRIDE; 53 virtual bool parseArcToSegment(float&, float&, float&, bool&, bool&, FloatPo int&) OVERRIDE;
54 54
55 #if COMPILER(MSVC) 55 #if COMPILER(MSVC)
56 #pragma warning(disable: 4701) 56 #pragma warning(disable: 4701)
57 #endif 57 #endif
58 template<typename DataType> 58 template<typename DataType>
59 DataType readType() 59 DataType readType()
60 { 60 {
61 ByteType<DataType> data; 61 ByteType<DataType> data;
62 size_t typeSize = sizeof(ByteType<DataType>); 62 size_t typeSize = sizeof(ByteType<DataType>);
63 63 ASSERT(m_streamCurrent + typeSize <= m_streamEnd);
64 for (size_t i = 0; i < typeSize; ++i) { 64 memcpy(data.bytes, m_streamCurrent, typeSize);
65 ASSERT(m_streamCurrent < m_streamEnd); 65 m_streamCurrent += typeSize;
66 data.bytes[i] = *m_streamCurrent;
67 ++m_streamCurrent;
68 }
69
70 return data.value; 66 return data.value;
71 } 67 }
72 68
73 bool readFlag() { return readType<bool>(); } 69 bool readFlag() { return readType<bool>(); }
74 float readFloat() { return readType<float>(); } 70 float readFloat() { return readType<float>(); }
75 unsigned short readSVGSegmentType() { return readType<unsigned short>(); } 71 unsigned short readSVGSegmentType() { return readType<unsigned short>(); }
76 FloatPoint readFloatPoint() 72 FloatPoint readFloatPoint()
77 { 73 {
78 float x = readType<float>(); 74 float x = readType<float>();
79 float y = readType<float>(); 75 float y = readType<float>();
80 return FloatPoint(x, y); 76 return FloatPoint(x, y);
81 } 77 }
82 78
83 SVGPathByteStream::DataIterator m_streamCurrent; 79 SVGPathByteStream::DataIterator m_streamCurrent;
84 SVGPathByteStream::DataIterator m_streamEnd; 80 SVGPathByteStream::DataIterator m_streamEnd;
85 }; 81 };
86 82
87 } // namespace WebCore 83 } // namespace WebCore
88 84
89 #endif // SVGPathByteStreamSource_h 85 #endif // SVGPathByteStreamSource_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698